Class: Eternity::ObjectTracker

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/eternity/object_tracker.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ObjectTracker

Returns a new instance of ObjectTracker.



7
8
9
# File 'lib/eternity/object_tracker.rb', line 7

def initialize(options)
  @changes = Restruct::MarshalArray.new options
end

Instance Method Details

#deleteObject



19
20
21
# File 'lib/eternity/object_tracker.rb', line 19

def delete
  track DELETE
end

#flattenObject



29
30
31
# File 'lib/eternity/object_tracker.rb', line 29

def flatten
  TrackFlatter.flatten changes
end

#insert(data) ⇒ Object



11
12
13
# File 'lib/eternity/object_tracker.rb', line 11

def insert(data)
  track INSERT, data
end

#revertObject



23
24
25
26
27
# File 'lib/eternity/object_tracker.rb', line 23

def revert
  locker.lock! :revert do
    changes.destroy
  end
end

#update(data) ⇒ Object



15
16
17
# File 'lib/eternity/object_tracker.rb', line 15

def update(data)
  track UPDATE, data
end