Class: Volt::ModelIdentityMap

Inherits:
GenericCountingPool show all
Defined in:
lib/volt/models/persistors/model_identity_map.rb

Overview

The identity map ensures that there is only one copy of a model used on the front end at a time.

Instance Attribute Summary

Attributes inherited from GenericPool

#pool

Instance Method Summary collapse

Methods inherited from GenericCountingPool

#find, #generate_new, #lookup, #remove, #transform_item

Methods inherited from GenericPool

#create_new_item, #initialize, #lookup, #lookup_all, #remove, #transform_item

Constructor Details

This class inherits a constructor from Volt::GenericPool

Instance Method Details

#add(id, model) ⇒ Object

add extends GenericCountingPool so it can add in a model without a direct lookup. We use this when we create a model (without an id) then save it and it gets assigned an id.



10
11
12
# File 'lib/volt/models/persistors/model_identity_map.rb', line 10

def add(id, model)
  @pool[id] = [1, model]
end