--- Eric Mahurin <eric_mahurin / yahoo.com> wrote:

> --- Logan Capaldo <logancapaldo / gmail.com> wrote:
> > On Jul 3, 2005, at 3:31 PM, Eric Mahurin wrote:
> > 
> > > Anybody know of a way to call an arbitrary method in the
> > > superclass?  In the current method, you can use "super"
> to
> > call
> > > the same method of the superclass, but how do you call
> > another?
> > >  The only way I can think of off hand is to alias the
> > > superclass methods to something else before creating the
> > > derived class definition.  But, that seems kind of ugly. 
> > It
> > > seems like there should be a way to call it directly
> using
> > > superclass or something.
> 
> > self.class.superclass.
> > instance_method(:some_method).bind(self).call(*args)
> 
> That is the magic I was looking for.  Thanks.
> 
> I think it would be nice if we had something like this in
> Object to make it easier (and faster when written in C):
> 
> class Object
> def super_method(sym)
>     self.class.superclass.instance_method(sym).bind(self)
> end
> def super_send(sym,*args)
>     super_method(sym).call(*args)
> end
> end

Forgot the bind(self).  Added it above.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com