Class: Mongoid::Persistence::Atomic::Rename

Inherits:
Object
  • Object
show all
Includes:
Operation
Defined in:
lib/mongoid/persistence/atomic/rename.rb

Overview

Performs an atomic rename operation.

Instance Attribute Summary

Attributes included from Operation

#document, #fields, #options, #value

Instance Method Summary collapse

Methods included from Operation

#collection, #initialize, #operation, #path, #prepare

Methods included from Atomic::Positionable

#positionally

Instance Method Details

#persistObject

Sends the atomic $inc operation to the database.

Examples:

Persist the new values.

inc.persist

Returns:

  • (Object)

    The new integer value.

Since:

  • 2.1.0



18
19
20
21
22
23
24
25
26
# File 'lib/mongoid/persistence/atomic/rename.rb', line 18

def persist
  prepare do
    @value = value.to_s
    document[value] = document.attributes.delete(field)
    execute("$rename")
    document.remove_change(value)
    document[value]
  end
end