Module: Mongoid::Commands::InstanceMethods
- Defined in:
- lib/mongoid/commands.rb
Instance Method Summary collapse
-
#delete ⇒ Object
Delete the
Document
from the database. -
#destroy ⇒ Object
Destroy the
Document
. -
#save ⇒ Object
Save the
Document
. -
#save! ⇒ Object
Save the
Document
. -
#update_attributes(attrs = {}) ⇒ Object
Update the attributes of the
Document
. -
#update_attributes!(attrs = {}) ⇒ Object
Update the attributes of the
Document
.
Instance Method Details
#delete ⇒ Object
Delete the Document
from the database. Delegates to the Delete command.
38 39 40 |
# File 'lib/mongoid/commands.rb', line 38 def delete Delete.execute(self) end |
#destroy ⇒ Object
Destroy the Document
. Delegates to the Destroy command.
43 44 45 |
# File 'lib/mongoid/commands.rb', line 43 def destroy Destroy.execute(self) end |
#save ⇒ Object
Save the Document
. Delegates to the Save command.
48 49 50 |
# File 'lib/mongoid/commands.rb', line 48 def save Save.execute(self) end |
#save! ⇒ Object
Save the Document
. Delegates to the Save command. If the command returns false then a ValidationError
will be raised.
54 55 56 |
# File 'lib/mongoid/commands.rb', line 54 def save! Save.execute(self) || (raise ValidationsError) end |
#update_attributes(attrs = {}) ⇒ Object
Update the attributes of the Document
. Will call save after the attributes have been updated.
60 61 62 |
# File 'lib/mongoid/commands.rb', line 60 def update_attributes(attrs = {}) write_attributes(attrs); save end |
#update_attributes!(attrs = {}) ⇒ Object
Update the attributes of the Document
. Will call save! after the attributes have been updated, causing a ValidationError
if the Document
failed validation.
67 68 69 |
# File 'lib/mongoid/commands.rb', line 67 def update_attributes!(attrs = {}) write_attributes(attrs); save! end |