Follow

In Ruby you can call a parent class’s method from another method in a child:

class Parent
def foo
1
end
end

class Child < Parent
def foo
2
end

def bar
Parent.instance_method(
:foo
).bind(self).call - foo
# == -1
end
end

You can also check whether a method has been overridden, but you have to be wary of modules.

method(:foo).owner == self.class

@sfcgeorge You could also just use alias and save yourself all that mad stuff

@sfcgeorge there is such place deep in `Net::HTTP` -- a method called `send`. I had to do the same thing to call it from the subclass instance.

Sign in to participate in the conversation
Ruby.social

A Mastodon instance for Rubyists & friends