From e1ecbe91693f7991a8d2224d4b0231d751f09a59 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 30 Jun 2005 15:22:00 +0000 Subject: [PATCH] * 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 --- ChangeLog | 5 +++++ lib/delegate.rb | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/ChangeLog b/ChangeLog index d0d27b241e..29cb438966 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Jul 1 00:18:40 2005 Yukihiro Matsumoto + + * lib/delegate.rb (Delegator::respond_to): respond_to? must check + destination object. [ruby-talk:146894] + Thu Jun 30 23:52:12 2005 Nobuyoshi Nakada * signal.c (trap): non-string trap hander was ignored. diff --git a/lib/delegate.rb b/lib/delegate.rb index 72b52f3d45..1d0ebed07a 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -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