Class: Redundancy::UpdateColumnWithPrev
- Inherits:
-
UpdateBase
- Object
- UpdateBase
- Redundancy::UpdateColumnWithPrev
- Defined in:
- lib/redundancy/update_column_with_prev.rb
Instance Attribute Summary
Attributes inherited from UpdateBase
#change_if, #dest, #klass, #options, #source
Instance Method Summary collapse
Methods inherited from UpdateBase
#after_save, #force_update!, #initialize
Constructor Details
This class inherits a constructor from Redundancy::UpdateBase
Instance Method Details
#before_save(record) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/redundancy/update_column_with_prev.rb', line 7 def before_save record raise_if_class_mismatch record return unless need_update? record get_target_from_association record get_value_from_association record update_target record return unless foreign_key_changed? record get_target_from_foreign_key record, :prev get_value_from_default record, :prev update_target record, :prev ensure cleanup_context end |