Class: Mongoid::Relations::Cascading::Destroy

Inherits:
Strategy show all
Defined in:
lib/mongoid/relations/cascading/destroy.rb

Instance Attribute Summary

Attributes inherited from Strategy

#document, #metadata, #relation

Instance Method Summary collapse

Methods inherited from Strategy

#initialize

Constructor Details

This class inherits a constructor from Mongoid::Relations::Cascading::Strategy

Instance Method Details

#cascadeObject

Execute the cascading deletion for the relation if it already exists. This should be optimized in the future potentially not to load all objects from the db.

Examples:

Perform the cascading destroy.

strategy.cascade


13
14
15
# File 'lib/mongoid/relations/cascading/destroy.rb', line 13

def cascade
  relation.to_a.each { |doc| doc.destroy } if relation
end