Class: CIA::Event
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- CIA::Event
- Defined in:
- lib/cia/event.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#add_attribute_changes(changes) ⇒ Object
tested via transaction_test.rb.
- #attribute_change_hash ⇒ Object
Class Method Details
.previous ⇒ Object
11 12 13 |
# File 'lib/cia/event.rb', line 11 def self.previous scoped(:order => "created_at desc") end |
Instance Method Details
#add_attribute_changes(changes) ⇒ Object
tested via transaction_test.rb
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cia/event.rb', line 22 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
15 16 17 18 19 |
# File 'lib/cia/event.rb', line 15 def attribute_change_hash attribute_changes.inject({}) do |h, a| h[a.attribute_name] = [a.old_value, a.new_value]; h end end |