module Mongoid::Relations::Cascading

This module defines the behaviour for setting up cascading deletes and nullifies for relations, and how to delegate to the approriate strategy.

Public Instance Methods

cascade!() click to toggle source

Perform all cascading deletes, destroys, or nullifies. Will delegate to the appropriate strategy to perform the operation.

@example Execute cascades.

document.cascade!

@since 2.0.0.rc.1

# File lib/mongoid/relations/cascading.rb, line 26
def cascade!
  cascades.each do |name|
    if !metadata || !metadata.versioned?
      if meta = relations[name]
        strategy = meta.cascade_strategy
        strategy.new(self, meta).cascade if strategy
      end
    end
  end
end