class Mongoid::Persistence::Atomic::PullAll

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

Public Instance Methods

persist() click to toggle source

Sends the atomic $pullAll operation to the database.

@example Persist the new values.

pull_all.persist

@return [ Object ] The new array value.

@since 2.0.0

# File lib/mongoid/persistence/atomic/pull_all.rb, line 18
def persist
  prepare do
    if document[field]
      values = document.send(field)
      values.delete_if { |val| value.include?(val) }
      execute("$pullAll")
      values
    end
  end
end