[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 7:59:00 PM

From: Gavin Kistner
> It's not pretty, but:
[snip]

Though, of course, you can make it prettier by making it re-usable:

class Object
def supercall( method_name, *args )
self.class.superclass.instance_method( method_name ).bind( self
).call( *args )
end
end

class Parent
def knox
puts 'parent'
end
end

class Child < Parent
def knox
puts 'child'
end
def test
supercall( :knox )
end
end