diff options
Diffstat (limited to 'lib/delegate.rb')
-rw-r--r-- | lib/delegate.rb | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/delegate.rb b/lib/delegate.rb index d810ccad42..1559c80542 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -115,6 +115,7 @@ # implementation, see SimpleDelegator. # class Delegator + IgnoreBacktracePat = %r"\A#{Regexp.quote(__FILE__)}:\d+:in `" # # Pass in the _obj_ to delegate method calls to. All methods supported by @@ -133,14 +134,12 @@ class Delegator for method in obj.methods next if preserved.include? method begin - eval <<-EOS + eval <<-EOS, nil, __FILE__, __LINE__+1 def self.#{method}(*args, &block) begin __getobj__.__send__(:#{method}, *args, &block) - rescue Exception - $@.delete_if{|s| /:in `__getobj__'$/ =~ s} #` - $@.delete_if{|s| /^\\(eval\\):/ =~ s} - Kernel::raise + ensure + $@.delete_if{|s|IgnoreBacktracePat=~s} end end EOS @@ -291,13 +290,12 @@ def DelegateClass(superclass) } for method in methods begin - klass.module_eval <<-EOS + klass.module_eval <<-EOS, __FILE__, __LINE__+1 def #{method}(*args, &block) begin @_dc_obj.__send__(:#{method}, *args, &block) - rescue - $@[0,2] = nil - raise + ensure + $@.delete_if{|s| ::Delegator::IgnoreBacktracePat =~ s} end end EOS |