Class: Mongoid::Relations::Cascading::Destroy
- Defined in:
- lib/mongoid/relations/cascading/destroy.rb
Instance Attribute Summary
Attributes inherited from Strategy
#document, #metadata, #relation
Instance Method Summary collapse
-
#cascade ⇒ Object
Execute the cascading deletion for the relation if it already exists.
Methods inherited from Strategy
Constructor Details
This class inherits a constructor from Mongoid::Relations::Cascading::Strategy
Instance Method Details
#cascade ⇒ Object
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.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/mongoid/relations/cascading/destroy.rb', line 13 def cascade if relation if relation.is_a?(Enumerable) relation.entries relation.each { |doc| doc.destroy } else relation.destroy end end end |