Module: Mongoid::Relations::Cascading

Extended by:
ActiveSupport::Concern
Included in:
Mongoid::Relations
Defined in:
lib/mongoid/relations/cascading.rb,
lib/mongoid/relations/cascading/delete.rb,
lib/mongoid/relations/cascading/destroy.rb,
lib/mongoid/relations/cascading/nullify.rb,
lib/mongoid/relations/cascading/restrict.rb

Overview

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

Defined Under Namespace

Modules: ClassMethods Classes: Delete, Destroy, Nullify, Restrict

Instance Method Summary collapse

Instance Method Details

#cascade!Object

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

Examples:

Execute cascades.

document.cascade!

Since:

  • 2.0.0.rc.1



27
28
29
30
31
32
33
34
# File 'lib/mongoid/relations/cascading.rb', line 27

def cascade!
  cascades.each do |name|
    if meta = relations[name]
      strategy = meta.cascade_strategy
      strategy.new(self, meta).cascade if strategy
    end
  end
end