Class: Mongoid::Persistence::Atomic::PullAll
- Includes:
- Operation
- Defined in:
- lib/mongoid/persistence/atomic/pull_all.rb
Overview
This class provides the ability to perform an explicit $pullAll modification on a specific field.
Instance Attribute Summary
Attributes included from Operation
#document, #field, #options, #value
Instance Method Summary collapse
-
#persist ⇒ Object
Sends the atomic $pullAll operation to the database.
Methods included from Operation
#collection, #initialize, #operation, #path, #prepare
Instance Method Details
#persist ⇒ Object
Sends the atomic $pullAll operation to the database.
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mongoid/persistence/atomic/pull_all.rb', line 19 def persist prepare do if document[field] values = document.send(field) values.delete_if { |val| value.include?(val) } values.tap do collection.update(document.atomic_selector, operation("$pullAll"), ) document.remove_change(field) if document.persisted? end end end end |