1 min read

TIL: Finding the Source of a Ruby Method

Find out where the source of a method is defined
TIL: Finding the Source of a Ruby Method
Photo by Radek Jedynak / Unsplash

Find out where the source of a method is defined.

If you've got a Method object reference to a class or instance's method, you can easily find out where it's defined:

Config.method(:setup).source_location
# ["/Users/billy/gems/config-2.2.1/lib/config.rb", 29]