lib/mongoid/association/depending.rb in mongoid-7.3.5 vs lib/mongoid/association/depending.rb in mongoid-7.4.0
- old
+ new
@@ -1,7 +1,6 @@
# frozen_string_literal: true
-# encoding: utf-8
module Mongoid
module Association
# This module defines the behavior for setting up cascading deletes and
@@ -29,12 +28,10 @@
end
end
end
# The valid dependent strategies.
- #
- # @since 7.0
STRATEGIES = [
:delete_all,
:destroy,
:nullify,
:restrict_with_exception,
@@ -48,12 +45,10 @@
# Mongoid::Association::Depending.define_dependency!(association)
#
# @param [ Association ] association The association metadata.
#
# @return [ Class ] The class of the document.
- #
- # @since 2.0.0.rc.1
def self.define_dependency!(association)
validate!(association)
association.inverse_class.tap do |klass|
if klass.dependents_owner != klass
klass.dependents = []
@@ -77,11 +72,9 @@
# Perform all cascading deletes, destroys, or nullifies. Will delegate to
# the appropriate strategy to perform the operation.
#
# @example Execute cascades.
# document.apply_destroy_dependencies!
- #
- # @since 2.0.0.rc.1
def apply_destroy_dependencies!
self.class._all_dependents.each do |association|
if dependent = association.try(:dependent)
send("_dependent_#{dependent}!", association)
end