Class: Recorder::Tape
- Inherits:
-
Object
- Object
- Recorder::Tape
- Defined in:
- lib/recorder/tape.rb
Instance Attribute Summary collapse
-
#item ⇒ Object
readonly
Returns the value of attribute item.
Instance Method Summary collapse
-
#initialize(item) ⇒ Tape
constructor
A new instance of Tape.
- #record_create ⇒ Object
- #record_destroy ⇒ Object
- #record_update ⇒ Object
Constructor Details
#initialize(item) ⇒ Tape
Returns a new instance of Tape.
5 6 7 |
# File 'lib/recorder/tape.rb', line 5 def initialize(item) @item = item; end |
Instance Attribute Details
#item ⇒ Object (readonly)
Returns the value of attribute item.
3 4 5 |
# File 'lib/recorder/tape.rb', line 3 def item @item end |
Instance Method Details
#record_create ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/recorder/tape.rb', line 9 def record_create data = { :changes => self.sanitize_attributes(self.item.attributes) } # changes.merge!(self.parse_associations_attributes) if data.any? self.record( Recorder.store.merge({ :event => :create, :data => data }) ) end end |
#record_destroy ⇒ Object
44 45 |
# File 'lib/recorder/tape.rb', line 44 def record_destroy end |
#record_update ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/recorder/tape.rb', line 26 def record_update data = { :changes => self.sanitize_attributes(self.item.previous_changes) } associations = self.parse_associations_attributes data.merge!(:associations => self.parse_associations_attributes) if associations.any? if data.any? self.record( Recorder.store.merge({ :event => :update, :data => data }) ) end end |