From: Brian Candler Date: 2003-07-15T23:56:20+09:00 Subject: Re: Custom method_missing doesn't trap super call On Tue, Jul 15, 2003 at 11:48:48PM +0900, Brian Candler wrote: > But you can now forget about class hierarchies, and deal with delegation > hierarchies instead. > > I find it's simplest and most powerful to explicitly keep track of objects > you want to delegate to. Here's a trivial example: P.S. I forgot the issue about 'super' which had been raised before, but when you do explicit delegation the problem vanishes: class Foo # the 'superclass' def meth1 puts "meth1 in #{self.class}" end end class Bar # the 'child' class def initialize @sup = Foo.new end def meth1 puts "meth1 in #{self.class}" @sup.meth1 # <----- end end c = Bar.new c.meth1 #>>meth1 in Bar #>>meth1 in Foo Of course you're not limited to one 'parent' object; you can decide to pass to one or more objects which you hold a reference to. Regards, Brian.