aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/module
diff options
context:
space:
mode:
authorBryan Helmkamp <bryan@brynary.com>2009-08-10 18:34:24 -0400
committerJeremy Kemper <jeremy@bitsweat.net>2009-08-10 18:48:38 -0500
commitd15ddf04ec6fb0cd6d350ba57d9981ebee3eddd0 (patch)
treed8f925967edb75edd2372f1b627667f5adb443af /activesupport/lib/active_support/core_ext/module
parentd0f891ae0215d7963b3918f3847ee4c015a6b90c (diff)
downloadrails-d15ddf04ec6fb0cd6d350ba57d9981ebee3eddd0.tar.gz
rails-d15ddf04ec6fb0cd6d350ba57d9981ebee3eddd0.tar.bz2
rails-d15ddf04ec6fb0cd6d350ba57d9981ebee3eddd0.zip
Allow delegating to nil, because the method might actually exist on it
Diffstat (limited to 'activesupport/lib/active_support/core_ext/module')
-rw-r--r--activesupport/lib/active_support/core_ext/module/delegation.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb
index 11e01437aa..df8aefea5a 100644
--- a/activesupport/lib/active_support/core_ext/module/delegation.rb
+++ b/activesupport/lib/active_support/core_ext/module/delegation.rb
@@ -120,10 +120,15 @@ class Module
end
module_eval(<<-EOS, file, line)
- def #{prefix}#{method}(*args, &block) # def customer_name(*args, &block)
- #{on_nil} if #{to}.nil?
- #{to}.__send__(#{method.inspect}, *args, &block) # client && client.__send__(:name, *args, &block)
- end # end
+ def #{prefix}#{method}(*args, &block) # def customer_name(*args, &block)
+ #{to}.__send__(#{method.inspect}, *args, &block) # client.__send__(:name, *args, &block)
+ rescue NoMethodError # rescue NoMethodError
+ if #{to}.nil? # if client.nil?
+ #{on_nil}
+ else # else
+ raise # raise
+ end # end
+ end # end
EOS
end
end