Class: ActiveRecord::Reflection::AssociationReflection::DynamicReflectionOptionsHash
- Inherits:
-
Hash
- Object
- Hash
- ActiveRecord::Reflection::AssociationReflection::DynamicReflectionOptionsHash
- Defined in:
- lib/dependent-auto-rails/activerecord/reflection.rb
Instance Method Summary collapse
Instance Method Details
#[](key) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/dependent-auto-rails/activerecord/reflection.rb', line 19 def [](key) return super unless key == :dependent && super(:dependent) == :auto return @dependent_auto if defined?(@dependent_auto) # The method returned here is only used to define an after_commit callback # for :destroy_async, so it doesn't really matter what we return. # This helps us since we can't yet determine the correct method as # the associated model might not have been evaluated. return fallback_method if defining_dependent_callbacks? @dependent_auto = begin model = super(:association_model_name).constantize if executable_callbacks_on_destroy_for(model).empty? case super(:association_type) when :singular then :delete when :collection then :delete_all else fallback_method end else :destroy end end end |