Class: Reactive::MetaModel::ActiveRecordInstance
- Inherits:
-
Object
- Object
- Reactive::MetaModel::ActiveRecordInstance
- Defined in:
- lib/activerecord_meta_model.rb
Instance Method Summary collapse
-
#initialize(instance) ⇒ ActiveRecordInstance
constructor
A new instance of ActiveRecordInstance.
-
#revert ⇒ Object
reload without hitting the database does not trigger observers.
Constructor Details
#initialize(instance) ⇒ ActiveRecordInstance
Returns a new instance of ActiveRecordInstance.
20 21 22 |
# File 'lib/activerecord_meta_model.rb', line 20 def initialize(instance) @instance = instance end |
Instance Method Details
#revert ⇒ Object
reload without hitting the database does not trigger observers
26 27 28 29 30 31 32 |
# File 'lib/activerecord_meta_model.rb', line 26 def revert @instance.instance_variable_set(:@marked_for_destruction, false) @instance.changes.each {|attr, (old,new)| @instance.send("#{attr}=", old) } @instance.send(:changed_attributes).clear @instance.class..has_manys.each {|| @instance.send(.name).each {|record| record.supra.revert} } @instance.class..has_ones.each {|| revert_assoc(@instance.send(.name)) } end |