Method: Mongoo::Cursor#obj_from_doc

Defined in:
lib/mongoo/cursor.rb

#obj_from_doc(doc) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/mongoo/cursor.rb', line 62

def obj_from_doc(doc)
  obj = nil
  if Mongoo::IdentityMap.on?
    if obj = Mongoo::IdentityMap.read(doc["_id"])
      obj.merge!(doc)
    end
  end
  obj ||= @obj_class.new(doc, true)
  Mongoo::IdentityMap.write(obj) if Mongoo::IdentityMap.on?
  obj
end