Module: ConfigureMe::Persisting
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#persist_guard(&block) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/configure_me/persisting.rb', line 38 def persist_guard(&block) if ConfigureMe.persistence_klass.respond_to?(:transaction) ConfigureMe.persistence_klass.transaction({}, &block) else block.call end end |
#read_persist(name) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/configure_me/persisting.rb', line 16 def read_persist(name) if self.class.persisting? setting = ConfigureMe.persistence_klass.find_by_key(self.storage_key(name)) unless setting.nil? YAML.load(setting.value) end else nil end end |
#write_persist(name, value) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/configure_me/persisting.rb', line 28 def write_persist(name, value) if self.class.persisting? setting = ConfigureMe.persistence_klass.find_or_create_by_key(self.storage_key(name)) setting.value = value.to_yaml setting.save! else true end end |