module Mongoid::Persistable::Pullable
def pull(pulls)
-
(Document)
- The document.
Parameters:
-
pulls
(Hash
) -- The field/value pull pairs.
Other tags:
- Note: - If duplicate values are found they will all be pulled.
Other tags:
- Example: Pull a value from the array. -
def pull(pulls) prepare_atomic_operation do |ops| process_atomic_operations(pulls) do |field, value| (send(field) || []).delete(value) ops[atomic_attribute_name(field)] = value end { "$pull" => ops } end end
def pull_all(pulls)
-
(Document)
- The document.
Parameters:
-
pulls
(Hash
) -- The pull all operations.
Other tags:
- Example: Pull values from the arrays. -
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