From: Surendra Singhi Date: 2006-09-13T20:04:28+09:00 Subject: Re: inheritance and super function "Sander Land" writes: > On 9/12/06, Surendra Singhi wrote: >> Now, in the function test in Class C, I want to call the test method defined >> in class A, by passing B's test method. >> >> How can I do this, just using plain 'super' doesn't work? Is it possible to do >> this? > > Use instance_method and bind. > > module Kernel > def super_n(n=1) > self.class.ancestors[n].instance_method(caller.first[/`(.*)'/][1..-2]).bind(self).call > end > end > Super cool, thanks a lot. -- Surendra Singhi http://ssinghi.kreeti.com, http://www.kreeti.com Read my blog at: http://cuttingtheredtape.blogspot.com/ ,---- | "War is Peace! Freedom is Slavery! Ignorance is Strength!" | -- Orwell, 1984, 1948 `----