class Mongoid::Persistence::Atomic::Pull

This class provides the ability to perform an explicit $pull modification on a specific field.

Public Instance Methods

persist() click to toggle source

Sends the atomic $pull operation to the database.

@example Persist the new values.

pull.persist

@return [ Object ] The new array value.

@since 2.1.0

# File lib/mongoid/persistence/atomic/pull.rb, line 18
def persist
  prepare do
    if document[field]
      values = document.send(field)
      values.delete(value)
      execute("$pull")
      values
    end
  end
end