Module: Mongoid::Locking::Persistable

Includes:
Creatable, Updatable
Defined in:
lib/mongoid/locking/persistable.rb,
lib/mongoid/locking/persistable/creatable.rb,
lib/mongoid/locking/persistable/updatable.rb

Overview

:nodoc:

Since:

  • 0.1.0

Defined Under Namespace

Modules: Creatable, Updatable

Instance Method Summary collapse

Methods included from Updatable

#update_document

Methods included from Creatable

#insert_as_embedded

Instance Method Details

#persist_atomic_operations(operations) ⇒ Object

Overrides the default Mongoid::Persistable#persist_atomic_operations to:

  • include the lock_version in the atomic selector

  • increment the lock_version in the atomic updates

Since:

  • 0.1.0



11
12
13
14
15
16
# File 'lib/mongoid/locking/persistable.rb', line 11

def persist_atomic_operations(operations)
  return unless persisted? && operations.present?

  selector = atomic_selector
  _update_one_locked(_root.collection, selector, operations)
end