提交 7dc03cfd 编写于 作者: J Jorge Bejar

Define array methods in ActiveRecord::Associations::CollectionProxy

if they are not defined or delegated.
In this way, we have a performance boost invoking some array methods
which are not defined in CollectionAssociation.
上级 7ecd6a73
......@@ -126,6 +126,19 @@ def reload
proxy_association.reload
self
end
# Define array public methods because we know it should be invoked over
# the target, so we can have a performance improvement using those methods
# in association collections
Array.public_instance_methods.each do |m|
unless method_defined?(m)
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{m}(*args, &block)
target.public_send(:#{m}, *args, &block) if load_target
end
RUBY
end
end
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册