Module: FmRest::Spyke::Model::Orm
- Extended by:
- ActiveSupport::Concern
- Included in:
- FmRest::Spyke::Model, Attributes
- Defined in:
- lib/fmrest/spyke/model/orm.rb
Instance Method Summary collapse
- #reload ⇒ Object
-
#save(options = {}) ⇒ Object
Completely override Spyke's save to provide a number of features:.
- #save!(options = {}) ⇒ Object
-
#update!(new_attributes) ⇒ Object
API-error-raising version of #update.
Instance Method Details
#reload ⇒ Object
104 105 106 107 108 |
# File 'lib/fmrest/spyke/model/orm.rb', line 104 def reload reloaded = self.class.find(id) self.attributes = reloaded.attributes self.mod_id = reloaded.mod_id end |
#save(options = {}) ⇒ Object
Completely override Spyke's save to provide a number of features:
- Validations
- Data API scripts execution
- Refresh of dirty attributes
84 85 86 87 88 89 90 91 |
# File 'lib/fmrest/spyke/model/orm.rb', line 84 def save( = {}) callback = persisted? ? :update : :create return false unless perform_save_validations(callback, ) return false unless perform_save_persistence(callback, ) true end |
#save!(options = {}) ⇒ Object
93 94 95 |
# File 'lib/fmrest/spyke/model/orm.rb', line 93 def save!( = {}) save(.merge(raise_validation_errors: true)) end |
#update!(new_attributes) ⇒ Object
API-error-raising version of #update
99 100 101 102 |
# File 'lib/fmrest/spyke/model/orm.rb', line 99 def update!(new_attributes) self.attributes = new_attributes save! end |