提交 70656c44 编写于 作者: R Ryuta Kamizono 提交者: GitHub

Merge pull request #30706 from tgxworld/fix_preload_memoization

PERF: Restore memoization when preloading associations.
......@@ -425,7 +425,6 @@ def compute_class(name)
def initialize(name, scope, options, active_record)
super
@automatic_inverse_of = nil
@type = options[:as] && (options[:foreign_type] || "#{options[:as]}_type")
@foreign_type = options[:foreign_type] || "#{name}_type"
@constructable = calculate_constructable(macro, options)
......@@ -609,12 +608,14 @@ def calculate_constructable(macro, options)
# If it cannot find a suitable inverse association name, it returns
# +nil+.
def inverse_name
options.fetch(:inverse_of) do
@automatic_inverse_of ||= automatic_inverse_of
unless defined?(@inverse_name)
@inverse_name = options.fetch(:inverse_of) { automatic_inverse_of }
end
@inverse_name
end
# returns either false or the inverse association name that it finds.
# returns either +nil+ or the inverse association name that it finds.
def automatic_inverse_of
if can_find_inverse_of_automatically?(self)
inverse_name = ActiveSupport::Inflector.underscore(options[:as] || active_record.name.demodulize).to_sym
......@@ -631,8 +632,6 @@ def automatic_inverse_of
return inverse_name
end
end
false
end
# Checks if the inverse reflection that is returned from the
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册