diff options
Diffstat (limited to 'app/models/setting.rb')
-rw-r--r-- | app/models/setting.rb | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/app/models/setting.rb b/app/models/setting.rb index c09b4bdb3..d4c82191a 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -27,16 +27,23 @@ class Setting < ActiveRecord::Base # Hash used to cache setting values @cached_settings = {} @cached_cleared_on = Time.now - + + def value + v = read_attribute(:value) + # Unserialize serialized settings + v = YAML::load(v) if @@available_settings[name]['serialized'] && v.is_a?(String) + v + end + # Returns the value of the setting named name def self.[](name) - value = @cached_settings[name] - value ? value : (@cached_settings[name] = find_or_default(name).value) + v = @cached_settings[name] + v ? v : (@cached_settings[name] = find_or_default(name).value) end - def self.[]=(name, value) + def self.[]=(name, v) setting = find_or_default(name) - setting.value = (value ? value.to_s : "") + setting.value = (v ? v : "") @cached_settings[name] = nil setting.save setting.value |