Module: DependentProtect::ClassMethods

Defined in:
lib/dependent_protect.rb

Instance Method Summary collapse

Instance Method Details

#has_and_belongs_to_many_with_protect(association_id, options = {}, &extension) ⇒ Object



38
39
40
41
42
43
# File 'lib/dependent_protect.rb', line 38

def has_and_belongs_to_many_with_protect(association_id, options = {}, &extension)
  reflection = create_reflection(:has_and_belongs_to_many, association_id, options, self)
  add_dependency_callback!(reflection, options)
  options.delete(:dependent)
  has_and_belongs_to_many_without_protect(association_id, options, &extension)
end

#has_many_with_protect(association_id, options = {}, &extension) ⇒ Object

:nodoc:



32
33
34
35
36
# File 'lib/dependent_protect.rb', line 32

def has_many_with_protect(association_id, options = {}, &extension) #:nodoc:
  reflection = create_reflection(:has_many, association_id, options, self)
  add_dependency_callback!(reflection, options)
  has_many_without_protect(association_id, options, &extension)
end

#has_one_with_protect(association_id, options = {}, &extension) ⇒ Object

We should be aliasing configure_dependency_for_has_many but that method is private so we can’t. We alias has_many instead trying to be as fair as we can to the original behaviour.



26
27
28
29
30
# File 'lib/dependent_protect.rb', line 26

def has_one_with_protect(association_id, options = {}, &extension) #:nodoc:
  reflection = create_reflection(:has_one, association_id, options, self)
  add_dependency_callback!(reflection, options)
  has_one_without_protect(association_id, options, &extension)
end