Skip to content

Commit

Permalink
Merge remote-tracking branch 'jmbejar/define_array_methods_collection…
Browse files Browse the repository at this point in the history
…_proxy'
  • Loading branch information
jonleighton committed Apr 25, 2012
2 parents 8b941e9 + 7dc03cf commit 2a97636
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions activerecord/lib/active_record/associations/collection_proxy.rb
Expand Up @@ -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

0 comments on commit 2a97636

Please sign in to comment.