Module: CIA::EventMethods
Instance Method Summary collapse
-
#add_attribute_changes(changes) ⇒ Object
tested via transaction_test.rb.
- #attribute_change_hash ⇒ Object
- #source_must_be_present? ⇒ Boolean
Instance Method Details
#add_attribute_changes(changes) ⇒ Object
tested via transaction_test.rb
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cia/event_methods.rb', line 30 def add_attribute_changes(changes) changes.each do |attribute_name, (old_value, new_value)| attribute_changes.build( event: self, attribute_name: attribute_name, old_value: old_value, new_value: new_value, source: source ) end end |
#attribute_change_hash ⇒ Object
23 24 25 26 27 |
# File 'lib/cia/event_methods.rb', line 23 def attribute_change_hash attribute_changes.inject({}) do |h, a| h[a.attribute_name] = [a.old_value, a.new_value]; h end end |
#source_must_be_present? ⇒ Boolean
42 43 44 |
# File 'lib/cia/event_methods.rb', line 42 def source_must_be_present? new_record? and action != "destroy" and (!attributes.key?("source_display_name") or source_display_name.blank?) end |