|
|
|
@ -136,11 +136,24 @@ class Setting < ActiveRecord::Base |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def value=(v) |
|
|
|
|
if v && @@available_settings[name] && @@available_settings[name]['serialized'] |
|
|
|
|
v = v.to_yaml |
|
|
|
|
write_attribute(:value, formatted_value(v)) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def formatted_value(value) |
|
|
|
|
return value unless value.present? |
|
|
|
|
|
|
|
|
|
default = @@available_settings[name] |
|
|
|
|
|
|
|
|
|
if default['serialized'] |
|
|
|
|
return value.to_yaml |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
write_attribute(:value, v.to_s) |
|
|
|
|
case default['format'] |
|
|
|
|
when "datetime" |
|
|
|
|
value.iso8601 |
|
|
|
|
else |
|
|
|
|
value.to_s |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
# Returns the value of the setting named name |
|
|
|
|