From dc11a77ab7730ec213b5042e1261a7be8c211396 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 14 Jan 2011 14:40:11 -0800 Subject: write the delegate method directly to avoid `delegate` callstack overhead --- activerecord/lib/active_record/associations/association_proxy.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb index b752f1fdc0..7f6e335858 100644 --- a/activerecord/lib/active_record/associations/association_proxy.rb +++ b/activerecord/lib/active_record/associations/association_proxy.rb @@ -51,7 +51,7 @@ module ActiveRecord # instantiation of the actual post records. class AssociationProxy #:nodoc: alias_method :proxy_extend, :extend - delegate :to_param, :to => :proxy_target + instance_methods.each { |m| undef_method m unless m.to_s =~ /^(?:nil\?|send|object_id|to_a)$|^__|^respond_to|proxy_/ } def initialize(owner, reflection) @@ -63,6 +63,10 @@ module ActiveRecord construct_scope end + def to_param + proxy_target.to_param + end + # Returns the owner of the proxy. def proxy_owner @owner -- cgit v1.2.3