Method: Mongoid::IdentityMap#get

Defined in:
lib/mongoid/identity_map.rb

#get(klass, identifier) ⇒ Document

Get a document from the identity map by its id.

Examples:

Get the document from the map.

map.get(Person, id)

Parameters:

  • klass (Class)

    The class of the document.

  • idenfier (Object, Hash)

    The document id or selector.

Returns:

Since:

  • 2.1.0



33
34
35
36
# File 'lib/mongoid/identity_map.rb', line 33

def get(klass, identifier)
  return nil unless Mongoid.identity_map_enabled? && klass
  documents_for(klass)[identifier]
end