Class: Mongoid::Persistence::Atomic::Rename
- Includes:
- Operation
- Defined in:
- lib/mongoid/persistence/atomic/rename.rb
Overview
Performs an atomic rename operation.
Instance Attribute Summary
Attributes included from Operation
#document, #field, #options, #value
Instance Method Summary collapse
-
#persist ⇒ Object
Sends the atomic $inc operation to the database.
Methods included from Operation
#collection, #initialize, #operation, #path, #prepare
Instance Method Details
#persist ⇒ Object
Sends the atomic $inc operation to the database.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mongoid/persistence/atomic/rename.rb', line 18 def persist prepare do @value = value.to_s document[value] = document.attributes.delete(field) document[value].tap do collection.update(document.atomic_selector, operation("$rename"), ) document.remove_change(value) end end end |