Class: Mongoid::Relations::Builders::NestedAttributes::Many

Inherits:
NestedBuilder
  • Object
show all
Defined in:
lib/mongoid/core_ext/builders/nested_attributes/many.rb

Instance Method Summary collapse

Instance Method Details

#destroy(parent, relation, doc) ⇒ Object

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.

Destroy the child document, needs to do some checking for embedded relations and delay the destroy in case parent validation fails.

Examples:

Destroy the child.

builder.destroy(parent, relation, doc)

Parameters:

  • parent (Document)

    The parent document.

  • relation (Proxy)

    The relation proxy.

  • doc (Document)

    The doc to destroy.

Since:

  • 3.0.10



22
23
24
25
26
27
28
# File 'lib/mongoid/core_ext/builders/nested_attributes/many.rb', line 22

def destroy(parent, relation, doc)
  if doc.paranoid?
    destroy_document(relation, doc)
  else
    original_destroy(parent, relation, doc)
  end
end

#original_destroyObject



7
# File 'lib/mongoid/core_ext/builders/nested_attributes/many.rb', line 7

alias_method :original_destroy, :destroy