Module: Toy::IdentityMap::ClassMethods

Defined in:
lib/toy/identity_map.rb

Instance Method Summary collapse

Instance Method Details

#get(id, options = nil) ⇒ Object



47
48
49
# File 'lib/toy/identity_map.rb', line 47

def get(id, options = nil)
  get_from_identity_map(id) || super
end

#load(id, attrs) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/toy/identity_map.rb', line 56

def load(id, attrs)
  if IdentityMap.enabled? && instance = IdentityMap.repository[id]
    instance
  else
    super.tap { |doc| doc.add_to_identity_map }
  end
end