[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Accessing base method...

Gavin Kistner

11/16/2006 6:33:00 PM

From: Soso Soso
> I'm new to ruby, being trying to access base class method but with no
> luck until now. Here's a snippet to get an idea:

It's not pretty, but:

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
#=> 'parent'