aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/association_proxy.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-01-09 18:33:51 +0000
committerAaron Patterson <aaron.patterson@gmail.com>2011-01-11 13:45:08 -0800
commit42b2e4f85bef64b7aa1382e96c79db1d4f318a56 (patch)
tree7df93ad2003cb94f014b406ca39266e36d36586d /activerecord/lib/active_record/associations/association_proxy.rb
parent3b797c8c8681c8f4619bce39d3f042244fe002d9 (diff)
downloadrails-42b2e4f85bef64b7aa1382e96c79db1d4f318a56.tar.gz
rails-42b2e4f85bef64b7aa1382e96c79db1d4f318a56.tar.bz2
rails-42b2e4f85bef64b7aa1382e96c79db1d4f318a56.zip
We can use the association_proxy method directly in HasOneThroughAssociation now
Diffstat (limited to 'activerecord/lib/active_record/associations/association_proxy.rb')
-rw-r--r--activerecord/lib/active_record/associations/association_proxy.rb35
1 files changed, 18 insertions, 17 deletions
diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb
index 294e1cab50..5fbda0bd3d 100644
--- a/activerecord/lib/active_record/associations/association_proxy.rb
+++ b/activerecord/lib/active_record/associations/association_proxy.rb
@@ -259,23 +259,6 @@ module ActiveRecord
end
end
- private
- # Forwards any missing method call to the \target.
- def method_missing(method, *args)
- if load_target
- unless @target.respond_to?(method)
- message = "undefined method `#{method.to_s}' for \"#{@target}\":#{@target.class.to_s}"
- raise NoMethodError, message
- end
-
- if block_given?
- @target.send(method, *args) { |*block_args| yield(*block_args) }
- else
- @target.send(method, *args)
- end
- end
- end
-
# Loads the \target if needed and returns it.
#
# This method is abstract in the sense that it relies on +find_target+,
@@ -299,6 +282,24 @@ module ActiveRecord
reset
end
+ private
+
+ # Forwards any missing method call to the \target.
+ def method_missing(method, *args)
+ if load_target
+ unless @target.respond_to?(method)
+ message = "undefined method `#{method.to_s}' for \"#{@target}\":#{@target.class.to_s}"
+ raise NoMethodError, message
+ end
+
+ if block_given?
+ @target.send(method, *args) { |*block_args| yield(*block_args) }
+ else
+ @target.send(method, *args)
+ end
+ end
+ end
+
# Should be true if there is a foreign key present on the @owner which
# references the target. This is used to determine whether we can load
# the target if the @owner is currently a new record (and therefore