DEV Community

Augusts Bautra
Augusts Bautra

Posted on

TIL #super_method

Consider this:

def name
  binding.pry

  "#{super} #{last_name}"
end
Enter fullscreen mode Exit fullscreen mode

You pry into a method and want to find out the source/location of other called methods. Usually this is easy, just method(:last_name).source or method(:last_name).source_location and voila. But what if the method calls super? 🤔

Not to worry, #super_method to the rescue:

> method(__method__).super_method.source
> method(__method__).super_method.source_location
Enter fullscreen mode Exit fullscreen mode

Top comments (0)