Last Updated: February 25, 2016
· jurisgalang

Locate a method's implementation

With Ruby 1.9.x the Method class now comes with #source_location -which comes in handy when you're spelunking:


- will return the actual path to the filename and line number where the method is defined:

["/path/to/some_file.rb", 42]

It wont work for natively compiled code, but you should still be able to just get an instance of the Method class and inspect it:


- to get the name of the Class or Module location where #host_mapping is defined:

#<Method: Account(Account::Url)#url>