Class: Recorder::Tape

Inherits:
Object
  • Object
show all
Defined in:
lib/recorder/tape.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#itemObject (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_createObject



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_destroyObject



44
45
# File 'lib/recorder/tape.rb', line 44

def record_destroy
end

#record_updateObject



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