* lib/delegate.rb (Delegator#method_missing),

(Delegator.delegating_block): don't hide backtrace from
  __getobj__ and reduced exception messages when $DEBUG.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-02-06 03:02:40 +00:00
Родитель 26b8c0890f
Коммит a6569ad637
2 изменённых файлов: 14 добавлений и 16 удалений

Просмотреть файл

@ -1,3 +1,9 @@
Sat Feb 6 12:02:36 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/delegate.rb (Delegator#method_missing),
(Delegator.delegating_block): don't hide backtrace from
__getobj__ and reduced exception messages when $DEBUG.
Sat Feb 6 11:35:08 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/socket/ipsocket.c (ip_addr, ip_peeraddr),

Просмотреть файл

@ -139,18 +139,11 @@ class Delegator < BasicObject
# Handles the magic of delegation through \_\_getobj\_\_.
def method_missing(m, *args, &block)
target = self.__getobj__
begin
target = self.__getobj__
unless target.respond_to?(m)
super(m, *args, &block)
else
target.__send__(m, *args, &block)
end
rescue ::Exception
if i = $@.index{|s| %r"\A#{Regexp.quote(__FILE__)}:\d+:in `method_missing'\z"o =~ s}
$@[0..i] = []
end
::Kernel::raise
target.respond_to?(m) ? target.__send__(m, *args, &block) : super(m, *args, &block)
ensure
$@.delete_if {|t| %r"\A#{Regexp.quote(__FILE__)}:#{__LINE__-2}:"o =~ t} if $@
end
end
@ -267,12 +260,11 @@ end
# :stopdoc:
def Delegator.delegating_block(mid)
lambda do |*args, &block|
target = self.__getobj__
begin
__getobj__.__send__(mid, *args, &block)
rescue
re = /\A#{Regexp.quote(__FILE__)}:#{__LINE__-2}:/o
$!.backtrace.delete_if {|t| re =~ t}
raise
target.__send__(mid, *args, &block)
ensure
$@.delete_if {|t| /\A#{Regexp.quote(__FILE__)}:#{__LINE__-2}:/o =~ t} if $@
end
end
end