Sha256: 1106136fd3dca10c60f89e7598151ccf2165cc059a5415132bb93a5c54d5dd70
Contents?: true
Size: 579 Bytes
Versions: 1
Compression:
Stored size: 579 Bytes
Contents
module RailsSettings class CachedSettings < Settings after_update :rewrite_cache after_create :rewrite_cache def rewrite_cache Rails.cache.write("settings:#{self.var}", self.value) end after_destroy { |record| Rails.cache.delete("settings:#{record.var}") } def self.[](var_name) obj = Rails.cache.fetch("settings:#{var_name}") { super(var_name) } obj || @@defaults[var_name.to_s] end def self.save_default(key,value) if self.send(key) == nil self.send("#{key}=",value) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails-settings-cached-0.2.4 | lib/rails-settings/cached_settings.rb |