2013-06-22 23:35:06 -04:00
|
|
|
module SiteSettings; end
|
|
|
|
|
|
|
|
class SiteSettings::LocalProcessProvider
|
|
|
|
|
2014-03-28 01:36:17 -04:00
|
|
|
attr_accessor :current_site
|
|
|
|
|
2013-07-04 02:49:17 -04:00
|
|
|
Setting = Struct.new(:name, :value, :data_type) unless defined? SiteSettings::LocalProcessProvider::Setting
|
2013-06-22 23:35:06 -04:00
|
|
|
|
2014-03-28 01:36:17 -04:00
|
|
|
def settings
|
|
|
|
@settings[current_site] ||= {}
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize()
|
2013-06-22 23:35:06 -04:00
|
|
|
@settings = {}
|
2014-03-28 01:36:17 -04:00
|
|
|
self.current_site = "test"
|
2013-06-22 23:35:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def all
|
2014-03-28 01:36:17 -04:00
|
|
|
settings.values
|
2013-06-22 23:35:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def find(name)
|
2014-03-28 01:36:17 -04:00
|
|
|
settings[name]
|
2013-06-22 23:35:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def save(name, value, data_type)
|
2015-09-09 09:34:53 -04:00
|
|
|
# NOTE: convert to string to simulate the conversion that is happening
|
|
|
|
# when using DbProvider
|
|
|
|
value = value.to_s
|
2015-09-09 06:59:49 -04:00
|
|
|
settings[name] = Setting.new(name, value, data_type)
|
2013-06-22 23:35:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy(name)
|
2014-03-28 01:36:17 -04:00
|
|
|
settings.delete(name)
|
2013-06-22 23:35:06 -04:00
|
|
|
end
|
|
|
|
|
2014-03-28 01:36:17 -04:00
|
|
|
def clear
|
|
|
|
@settings[current_site] = {}
|
2013-06-22 23:35:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|