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