lib/adaptive_alias.rb in adaptive_alias-1.2.1 vs lib/adaptive_alias.rb in adaptive_alias-1.3.0
- old
+ new
@@ -12,10 +12,11 @@
require 'adaptive_alias/hooks/association'
require 'adaptive_alias/hooks/relation'
require 'adaptive_alias/hooks/active_record_core'
require 'adaptive_alias/hooks/active_record_persistence'
require 'adaptive_alias/hooks/calculations'
+require 'adaptive_alias/hooks/insert_all'
module AdaptiveAlias
@log_interval = 10 * 60
@current_patches = {}
@model_modules ||= {}
@@ -40,17 +41,17 @@
patch.mark_removable
end
end
end
- def rescue_statement_invalid(relation: nil, reflection: nil, model: nil, &block)
+ def rescue_statement_invalid(relation: nil, reflection: nil, model_klass: nil, &block)
yield
rescue ActiveRecord::StatementInvalid => error
- _key, patch = AdaptiveAlias.current_patches.find{|_key, patch| patch.check_matched.call(relation, reflection, model, error) }
+ _key, patch = AdaptiveAlias.current_patches.find{|_key, patch| patch.check_matched.call(relation, reflection, model_klass, error) }
raise error if patch == nil
patch.remove_and_fix_association.call(relation, reflection) do
- return rescue_statement_invalid(relation: relation, reflection: reflection, model: model, &block)
+ return rescue_statement_invalid(relation: relation, reflection: reflection, model_klass: model_klass, &block)
end
end
def get_or_create_model_module(klass)
return @model_modules[klass] if @model_modules[klass]