2013-06-22 23:35:06 -04:00
|
|
|
module SiteSettings; end
|
|
|
|
|
|
|
|
class SiteSettings::LocalProcessProvider
|
|
|
|
|
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
|
|
|
|
2013-10-23 19:05:51 -04:00
|
|
|
def initialize(defaults = {})
|
2013-06-22 23:35:06 -04:00
|
|
|
@settings = {}
|
2013-10-23 19:05:51 -04:00
|
|
|
@defaults = {}
|
|
|
|
defaults.each do |name,(value,data_type)|
|
|
|
|
@defaults[name] = Setting.new(name,value,data_type)
|
|
|
|
end
|
2013-06-22 23:35:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def all
|
2013-10-23 19:05:51 -04:00
|
|
|
(@defaults.merge @settings).values
|
2013-06-22 23:35:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def find(name)
|
2013-10-23 19:05:51 -04:00
|
|
|
@settings[name] || @defaults[name]
|
2013-06-22 23:35:06 -04: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
|