Method: Mongoid::Persistable::Pullable#pull_all

Defined in:
lib/mongoid/persistable/pullable.rb

#pull_all(pulls) ⇒ Document

Pull multiple values from the provided array fields.

Examples:

Pull values from the arrays.

document.pull_all(names: [ "Jeff", "Bob" ], levels: [ 5, 6 ])

Parameters:

  • pulls (Hash)

    The pull all operations.

Returns:



39
40
41
42
43
44
45
46
47
48
# File 'lib/mongoid/persistable/pullable.rb', line 39

def pull_all(pulls)
  prepare_atomic_operation do |ops|
    process_atomic_operations(pulls) do |field, value|
      existing = send(field) || []
      value.each{ |val| existing.delete(val) }
      ops[atomic_attribute_name(field)] = value
    end
    { "$pullAll" => ops }
  end
end