Module: Mongoid::Persistable
- Extended by:
- ActiveSupport::Concern
- Includes:
- Creatable, Deletable, Destroyable, Incrementable, Logical, Poppable, Pullable, Pushable, Renamable, Savable, Settable, Unsettable, Updatable, Upsertable, Positional
- Included in:
- Composable
- Defined in:
- lib/mongoid/persistable.rb,
lib/mongoid/persistable/logical.rb,
lib/mongoid/persistable/savable.rb,
lib/mongoid/persistable/poppable.rb,
lib/mongoid/persistable/pullable.rb,
lib/mongoid/persistable/pushable.rb,
lib/mongoid/persistable/settable.rb,
lib/mongoid/persistable/creatable.rb,
lib/mongoid/persistable/deletable.rb,
lib/mongoid/persistable/renamable.rb,
lib/mongoid/persistable/updatable.rb,
lib/mongoid/persistable/unsettable.rb,
lib/mongoid/persistable/upsertable.rb,
lib/mongoid/persistable/destroyable.rb,
lib/mongoid/persistable/incrementable.rb
Overview
Contains general behaviour for persistence operations.
Defined Under Namespace
Modules: Creatable, Deletable, Destroyable, Incrementable, Logical, Poppable, Pullable, Pushable, Renamable, Savable, Settable, Unsettable, Updatable, Upsertable
Instance Method Summary collapse
-
#atomically ⇒ true, false
Execute operations atomically (in a single database call) for everything that would happen inside the block.
-
#fail_due_to_callback!(method) ⇒ Object
Raise an error if a callback failed.
-
#fail_due_to_validation! ⇒ Object
Raise an error if validation failed.
Methods included from Unsettable
Methods included from Upsertable
Methods included from Updatable
#update, #update!, #update_attribute, #update_document
Methods included from Settable
Methods included from Savable
Methods included from Renamable
Methods included from Pushable
Methods included from Pullable
Methods included from Positional
Methods included from Poppable
Methods included from Logical
Methods included from Incrementable
Methods included from Destroyable
Methods included from Deletable
Methods included from Creatable
Instance Method Details
#atomically ⇒ true, false
Execute operations atomically (in a single database call) for everything that would happen inside the block.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/mongoid/persistable.rb', line 51 def atomically begin @atomic_updates_to_execute = {} yield(self) if block_given? persist_atomic_operations(@atomic_updates_to_execute) true ensure @atomic_updates_to_execute = nil end end |
#fail_due_to_callback!(method) ⇒ Object
Raise an error if a callback failed.
87 88 89 |
# File 'lib/mongoid/persistable.rb', line 87 def fail_due_to_callback!(method) raise Errors::Callback.new(self.class, method) end |
#fail_due_to_validation! ⇒ Object
Raise an error if validation failed.
72 73 74 |
# File 'lib/mongoid/persistable.rb', line 72 def fail_due_to_validation! raise Errors::Validations.new(self) end |