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