Method: Mongo::Object#create_object

Defined in:
lib/mongo/object/object.rb

#create_object(collection, options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/mongo/object/object.rb', line 8

def create_object collection, options
  doc = to_mongo

  # Generating custom id if option enabled.
  doc['_id'] ||= generate_id if Mongo.defaults[:generate_id]

  id = collection.create doc, options

  self._id ||= id
  self._not_new = true

  id
end