Module: DeepStore::Model::Persistence
- Defined in:
- lib/deep_store/model/persistence.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/deep_store/model/persistence.rb', line 4 def self.included(base) base.extend(ClassMethods) base.class_eval do attr_accessor :persisted def persisted? return(@persisted) if defined?(@persisted) @persisted = false end def save return unless __repository__.save(self) @persisted = true end def destroy __repository__.destroy(key) @persisted = true end def key KeyFactory.call(self, __settings__.fetch(:key)) end end end |