Class: Paquito::ActiveRecordCoder::InstanceTracker
- Inherits:
-
Object
- Object
- Paquito::ActiveRecordCoder::InstanceTracker
- Defined in:
- lib/paquito/active_record_coder.rb
Instance Method Summary collapse
- #fetch(*args, &block) ⇒ Object
-
#initialize ⇒ InstanceTracker
constructor
A new instance of InstanceTracker.
- #lookup(instance) ⇒ Object
- #map(&block) ⇒ Object
- #push(instance) ⇒ Object
Constructor Details
#initialize ⇒ InstanceTracker
Returns a new instance of InstanceTracker.
142 143 144 145 |
# File 'lib/paquito/active_record_coder.rb', line 142 def initialize @instances = [] @ids = {}.compare_by_identity end |
Instance Method Details
#fetch(*args, &block) ⇒ Object
151 152 153 |
# File 'lib/paquito/active_record_coder.rb', line 151 def fetch(*args, &block) @instances.fetch(*args, &block) end |
#lookup(instance) ⇒ Object
162 163 164 |
# File 'lib/paquito/active_record_coder.rb', line 162 def lookup(instance) @ids[instance] end |
#map(&block) ⇒ Object
147 148 149 |
# File 'lib/paquito/active_record_coder.rb', line 147 def map(&block) @instances.map(&block) end |
#push(instance) ⇒ Object
156 157 158 159 160 |
# File 'lib/paquito/active_record_coder.rb', line 156 def push(instance) id = @ids[instance] = @instances.size @instances << instance id end |