diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/module')
-rw-r--r-- | activesupport/lib/active_support/core_ext/module/delegation.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb index c979af9de3..1840dc942f 100644 --- a/activesupport/lib/active_support/core_ext/module/delegation.rb +++ b/activesupport/lib/active_support/core_ext/module/delegation.rb @@ -273,10 +273,16 @@ class Module def method_missing(method, *args, &block) if #{target}.respond_to?(method) #{target}.public_send(method, *args, &block) - elsif #{target}.nil? - raise DelegationError, "\#{method} delegated to #{target}, but #{target} is nil" else - super + begin + super + rescue NoMethodError + if #{target}.nil? + raise DelegationError, "\#{method} delegated to #{target}, but #{target} is nil" + else + raise + end + end end end RUBY |