Permalink
Browse files

Rely on NoMethodError#name when deciding to raise DelegationError.

Different Ruby implementations present backtraces differently, as
it should be an information consumed by humans.
A better implementation should use data from the error, in this case
returned by NoMethodError#name.

Fixes issues with Rubinius, which presents backtraces differently from
MRI.
  • Loading branch information...
1 parent 0f83486 commit cbd2111c67b1603c97c00ebbd5f6f67e4b24eebd @razielgn razielgn committed Aug 12, 2013
Showing with 1 addition and 2 deletions.
  1. +1 −2 activesupport/lib/active_support/core_ext/module/delegation.rb
@@ -192,8 +192,7 @@ def #{method_prefix}#{method}(#{definition})
_ = #{to} # _ = client
_.#{method}(#{definition}) # _.name(*args, &block)
rescue NoMethodError => e # rescue NoMethodError => e
- location = "%s:%d:in `%s'" % [__FILE__, __LINE__ - 2, '#{method_prefix}#{method}'] # location = "%s:%d:in `%s'" % [__FILE__, __LINE__ - 2, 'customer_name']
- if _.nil? && e.backtrace.first == location # if _.nil? && e.backtrace.first == location
+ if _.nil? && e.name == :#{method} # if _.nil? && e.name == :name
#{exception} # # add helpful message to the exception
else # else
raise # raise

0 comments on commit cbd2111

Please sign in to comment.