Skip to content

Instantly share code, notes, and snippets.

@leemour
Last active June 28, 2018 02:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leemour/e4f31a16bfd25b15550a42831f08ddb7 to your computer and use it in GitHub Desktop.
Save leemour/e4f31a16bfd25b15550a42831f08ddb7 to your computer and use it in GitHub Desktop.
Ruby reflections - find source location and source code
# Show method location
method(:meth).source_location
# Nice gem 'method_source' makes life easier. Use it inside console:
require 'method_source'
# Show method source
method(:meth).source.display
# Show class or method definition
show-source Job
show-source Job.work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment