Module: Mongoid::Relations::Embedded::Batchable

Defined in:
lib/mongoid/core_ext/relations/embedded/batchable.rb

Instance Method Summary collapse

Instance Method Details

#pre_process_batch_remove(docs, method) ⇒ Array<Hash>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Pre process the batch removal.

Examples:

Pre process the documents.

batchable.pre_process_batch_remove(docs, :delete)

Parameters:

  • docs (Array<Document>)

    The documents.

  • method (Symbol)

    Delete or destroy.

Returns:

  • (Array<Hash>)

    The documents as hashes.

Since:

  • 3.0.0



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mongoid/core_ext/relations/embedded/batchable.rb', line 18

def pre_process_batch_remove(docs, method)
  docs.map do |doc|
    self.path = doc.atomic_path unless path
    execute_callback :before_remove, doc
    if !_assigning? && !.versioned?
      doc.cascade!
      doc.run_before_callbacks(:destroy) if method == :destroy
    end
    target.delete_one(doc)
    _unscoped.delete_one(doc)
    unbind_one(doc)
    execute_callback :after_remove, doc
    doc.as_document
  end
end