trabajo-afectivo/app/models/setting.rb

29 lines
530 B
Ruby
Raw Normal View History

2012-04-10 14:06:46 +00:00
class Setting < ActiveRecord::Base
store :options
store :state
store :state_initial
before_create :set_initial
@@config = nil
def self.load
return @@config if @@config
config = {}
Setting.select('name, state').order(:id).each { |setting|
config[setting.name] = setting.state[:value]
}
@@config = config
return config
end
def self.get(name)
self.load
return @@config[name]
end
private
def set_initial
self.state_initial = self.state
end
end