Class: Perpetuity::DirtyTracker
- Inherits:
-
Object
- Object
- Perpetuity::DirtyTracker
- Defined in:
- lib/perpetuity/dirty_tracker.rb
Instance Method Summary collapse
- #<<(object) ⇒ Object
- #[](klass, id) ⇒ Object
-
#initialize ⇒ DirtyTracker
constructor
A new instance of DirtyTracker.
Constructor Details
#initialize ⇒ DirtyTracker
Returns a new instance of DirtyTracker.
5 6 7 |
# File 'lib/perpetuity/dirty_tracker.rb', line 5 def initialize @map = Hash.new { |hash, key| hash[key] = {} } end |
Instance Method Details
#<<(object) ⇒ Object
13 14 15 16 17 |
# File 'lib/perpetuity/dirty_tracker.rb', line 13 def << object klass = object.class id = object.instance_variable_get(:@id) @map[klass][id.to_s] = object.dup end |
#[](klass, id) ⇒ Object
9 10 11 |
# File 'lib/perpetuity/dirty_tracker.rb', line 9 def [] klass, id @map[klass][id.to_s] end |