Method: Mongoid::Relations::Cascading::Destroy#cascade
- Defined in:
- lib/mongoid/relations/cascading/destroy.rb
#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.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mongoid/relations/cascading/destroy.rb', line 30 def cascade if relation if relation.is_a?(Enumerable) relation.entries relation.each { |doc| doc.destroy } else relation.destroy end end end |