On 07 Jun 2005, at 08:05, curtis.schofield / gmail.com wrote:

> Hi, I'm trying to use respond_to on a class for the purpose of  
> getting DRb to work with method_missing. This is basically what i  
> am doing. The situation is that i'm not getting the proper  
> execution of methods if i use respond_to in this manner with  
> method_missing.
>
> If i don't have a return true for @childrenArray in the respond_to  
> then things seem to work, otherwise it seems to call the  
> method_missing but the return value from the @childArray send  
> doesn't seem to make it.. to_ary is being called , i'm trying to  
> call Foo.flatten.uniq
>
> Any Suggestions?

Let ruby do more work for you.

Would Delegator or Forwardable be of assistance?

class Foo

   # no need to alias respond_to?, it is available from the superclass.

   def respond_to?(meth)
     return true if @childrenArray.respond_to? meth
     return super
   end

   # I always break method apart, because its always there
   # Don't forget the block, unless you don't need it
   # No need to check for respond_to?  Ruby will DTRT

   def method_missing(meth, *args, &block)
     return @childrenArray.send(meth, *args, &block)
   end

end

-- 
Eric Hodel - drbrain / segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E  7C11 332A 551C 796C 9F04