Class: Mongoid::Commands::Create

Inherits:
Object
  • Object
show all
Defined in:
lib/mongoid/commands/create.rb

Class Method Summary collapse

Class Method Details

.execute(doc) ⇒ Object

Performs a create of the supplied Document, with the necessary callbacks. It then delegates to the Save command.

Options:

doc: A new Document that is going to be persisted.

Returns: Document.



13
14
15
16
17
18
# File 'lib/mongoid/commands/create.rb', line 13

def self.execute(doc)
  doc.run_callbacks :before_create
  Save.execute(doc)
  doc.run_callbacks :after_create
  return doc
end