Class: Redundancy::UpdatePrevMethod

Inherits:
UpdateBase show all
Defined in:
lib/redundancy/update_prev_method.rb

Instance Attribute Summary

Attributes inherited from UpdateBase

#change_if, #dest, #force, #klass, #options, #source, #target, #update, #value

Instance Method Summary collapse

Methods inherited from UpdateBase

#force_update!, #force_update_target, #get_target_from_association, #get_target_from_prev_id, #get_target_from_relation_first_record, #get_value_from_association, #get_value_from_source, #get_value_from_target, #initialize, #log, #need_update?, #raise_if_class_mismatch, #update_target

Constructor Details

This class inherits a constructor from Redundancy::UpdateBase

Instance Method Details

#after_save(record) ⇒ Object



15
16
17
18
19
20
# File 'lib/redundancy/update_prev_method.rb', line 15

def after_save record
  return unless target

  get_value_from_target record
  force_update_target record
end

#before_save(record) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/redundancy/update_prev_method.rb', line 7

def before_save record
  raise_if_class_mismatch record
  return unless need_update? record

  get_target_from_prev_id record
  get_target_from_relation_first_record
end