Class: Mongoid::Persistence::Atomic::Unset

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

Overview

Performs atomic $unset operations.

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

#persistnil

Sends the atomic $unset operation to the database.

Examples:

Persist the new values.

unset.persist

Returns:

  • (nil)

    The new value.

Since:

  • 2.1.0



18
19
20
21
22
23
# File 'lib/mongoid/persistence/atomic/unset.rb', line 18

def persist
  prepare do
    fields.each { |f| document.attributes.delete(f) }
    execute("$unset")
  end
end