From: hemant Date: 2006-12-06T20:58:26+09:00 Subject: Re: Calling super in overwritten methods On 12/6/06, Joerg Diekmann wrote: > Hi - not sure if this is possible - but it feels like it could be with > some serious ruby-fu. > > I have the following: > > class A > def method1 > method2 > end > > def method2 > return 100 > end > end > > class B < A > def method1 > super > end > > def method2 > return 200 > end > end > > > This is what happens: > > b.method1 # 200 > > But, what I want is: > > b.method1 # 100 > > > Is this possible at all? > > Thanks > Joerg Indeed but sometime back, we had similar discussion here and someone (David I guess) proposed: class Parent def knox puts 'parent' end end class Child < Parent def knox puts 'child' end def test self.class.superclass.instance_method( :knox ).bind( self ).call end end Child.new.test -- There was only one Road; that it was like a great river: its springs were at every doorstep, and every path was its tributary.