lib/adaptive_alias.rb in adaptive_alias-1.0.0 vs lib/adaptive_alias.rb in adaptive_alias-1.1.0

- old
+ new

@@ -12,10 +12,11 @@ require 'adaptive_alias/hooks/association' require 'adaptive_alias/hooks/association_scope' require 'adaptive_alias/hooks/singular_association' require 'adaptive_alias/hooks/relation' require 'adaptive_alias/hooks/active_record_core' +require 'adaptive_alias/hooks/active_record_persistence' module AdaptiveAlias @log_interval = 10 * 60 @current_patches = {} @model_modules ||= {} @@ -40,15 +41,15 @@ patch.mark_removable end end end - def rescue_statement_invalid(relation, reflection, &block) + def rescue_statement_invalid(relation: nil, reflection: nil, model: nil, &block) yield rescue ActiveRecord::StatementInvalid => error - raise error if AdaptiveAlias.current_patches.all?{|_key, patch| !patch.fix_association.call(relation, reflection, error) } + raise error if AdaptiveAlias.current_patches.all?{|_key, patch| !patch.fix_association.call(relation, reflection, model, error) } - result = rescue_statement_invalid(relation, reflection, &block) + result = rescue_statement_invalid(relation: relation, reflection: reflection, model: model, &block) AdaptiveAlias.current_patches.each_value(&:mark_removable) return result end def rescue_missing_attribute(klass, &block)