提交 4e93179e 编写于 作者: C Carlos Antonio da Silva 提交者: José Valim

Refactor AssociationCollection#include? with objects in memory

Signed-off-by: NJosé Valim <jose.valim@gmail.com>
上级 b9515220
......@@ -558,11 +558,10 @@ def fetch_first_or_last_using_find?(args)
def include_in_memory?(record)
if @reflection.is_a?(ActiveRecord::Reflection::ThroughReflection)
@owner.send(proxy_reflection.through_reflection.name.to_sym).map do |source|
source_reflection_target = source.send(proxy_reflection.source_reflection.name)
return true if source_reflection_target.respond_to?(:include?) ? source_reflection_target.include?(record) : source_reflection_target == record
@owner.send(proxy_reflection.through_reflection.name.to_sym).any? do |source|
target = source.send(proxy_reflection.source_reflection.name)
target.respond_to?(:include?) ? target.include?(record) : target == record
end
false
else
@target.include?(record)
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册