Re: Accessing base method

From: Soso S.

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’