Module: Mince::Model::Persistence
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/mince/model/persistence.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#persisted? ⇒ Boolean
Returns true if the record indicates that it has been persisted to a data model.
-
#save ⇒ Object
Saves the object to the data model.
Instance Method Details
#persisted? ⇒ Boolean
Returns true if the record indicates that it has been persisted to a data model. Returns false otherwise.
28 29 30 |
# File 'lib/mince/model/persistence.rb', line 28 def persisted? !!id end |
#save ⇒ Object
Saves the object to the data model. Stores if new, updates previous entry if it has already been saved.
34 35 36 37 38 39 40 41 42 |
# File 'lib/mince/model/persistence.rb', line 34 def save ensure_no_extra_fields if self.respond_to?(:ensure_no_extra_fields, true) if persisted? data_model.update(self) else @id = data_model.store(self) end end |