Sha256: 5f7a5dce3226494d6228c964209f7e1f912e76879e4cd02de68bc017e7048c84
Contents?: true
Size: 835 Bytes
Versions: 4
Compression:
Stored size: 835 Bytes
Contents
module Radmin def self.table_name_prefix; "radmin_"; end class Setting < ActiveRecord::Base after_save { Rails.cache.write('Radmin::Settings',Radmin::Setting.to_hash) } class << self def [](key) settings = Rails.cache.fetch('Radmin::Settings') { Radmin::Setting.to_hash } settings[key] end def []=(key, value) pair = find_or_initialize_by_key(key) pair.update_attributes(:value => value) value end def to_hash Hash[ *find(:all).map { |pair| [pair.key, pair.value] }.flatten ] end end def value=(param) self[:value] = param.to_s end def value unless new_record? if key.ends_with? "?" self[:value] == "true" else self[:value] end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
radmin-0.3.3 | app/models/radmin/setting.rb |
radmin-0.3.2 | app/models/radmin/setting.rb |
radmin-0.3.1 | app/models/radmin/setting.rb |
radmin-0.2.0 | app/models/radmin/setting.rb |