mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/delegate.rb (Delegator::respond_to): respond_to? must check
destination object. [ruby-talk:146894] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
46a14a29fc
commit
e1ecbe9169
2 changed files with 14 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri Jul 1 00:18:40 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* lib/delegate.rb (Delegator::respond_to): respond_to? must check
|
||||
destination object. [ruby-talk:146894]
|
||||
|
||||
Thu Jun 30 23:52:12 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* signal.c (trap): non-string trap hander was ignored.
|
||||
|
|
|
@ -57,6 +57,11 @@ class Delegator
|
|||
target.__send__(m, *args)
|
||||
end
|
||||
|
||||
def respond_to?(m)
|
||||
return true if super
|
||||
return self.__getobj__.respond_to?(m)
|
||||
end
|
||||
|
||||
def __getobj__
|
||||
raise NotImplementedError, "need to define `__getobj__'"
|
||||
end
|
||||
|
@ -115,6 +120,10 @@ def DelegateClass(superclass)
|
|||
end
|
||||
@_dc_obj.__send__(m, *args)
|
||||
end
|
||||
def respond_to?(m)
|
||||
return true if super
|
||||
return @_dc_obj.respond_to?(m)
|
||||
end
|
||||
def __getobj__
|
||||
@_dc_obj
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue