diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-14 14:40:11 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-14 14:40:11 -0800 |
commit | dc11a77ab7730ec213b5042e1261a7be8c211396 (patch) | |
tree | 33142eb3a3684de6c0ae1fcff2bf6ea5562d5930 /activerecord/lib | |
parent | ef4ffed660015772f67826e8aaa319febe84f271 (diff) | |
download | rails-dc11a77ab7730ec213b5042e1261a7be8c211396.tar.gz rails-dc11a77ab7730ec213b5042e1261a7be8c211396.tar.bz2 rails-dc11a77ab7730ec213b5042e1261a7be8c211396.zip |
write the delegate method directly to avoid `delegate` callstack overhead
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/association_proxy.rb | 6 |
1 files changed, 5 insertions, 1 deletions
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 |