From cbd2111c67b1603c97c00ebbd5f6f67e4b24eebd Mon Sep 17 00:00:00 2001 From: Federico Ravasio Date: Mon, 12 Aug 2013 11:43:42 +0200 Subject: 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. --- activesupport/lib/active_support/core_ext/module/delegation.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb index bca3800344..182e74d9e1 100644 --- a/activesupport/lib/active_support/core_ext/module/delegation.rb +++ b/activesupport/lib/active_support/core_ext/module/delegation.rb @@ -192,8 +192,7 @@ class Module _ = #{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 -- cgit v1.2.3