2013-06-23 11:35:06 +08:00
|
|
|
module SiteSettings; end
|
|
|
|
|
|
|
|
class SiteSettings::LocalProcessProvider
|
|
|
|
|
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
|
|
|
|
2013-10-24 07:05:51 +08:00
|
|
|
def initialize(defaults = {})
|
2013-06-23 11:35:06 +08:00
|
|
|
@settings = {}
|
2013-10-24 07:05:51 +08:00
|
|
|
@defaults = {}
|
|
|
|
defaults.each do |name,(value,data_type)|
|
|
|
|
@defaults[name] = Setting.new(name,value,data_type)
|
|
|
|
end
|
2013-06-23 11:35:06 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def all
|
2013-10-24 07:05:51 +08:00
|
|
|
(@defaults.merge @settings).values
|
2013-06-23 11:35:06 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def find(name)
|
2013-10-24 07:05:51 +08:00
|
|
|
@settings[name] || @defaults[name]
|
2013-06-23 11:35:06 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def save(name, value, data_type)
|
|
|
|
@settings[name] = Setting.new(name,value, data_type)
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy(name)
|
|
|
|
@settings.delete(name)
|
|
|
|
end
|
|
|
|
|
|
|
|
def current_site
|
|
|
|
"test"
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|