Skip to content

Instantly share code, notes, and snippets.

@marianposaceanu
Last active February 22, 2016 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marianposaceanu/1dd65a908f00db22cb9f to your computer and use it in GitHub Desktop.
Save marianposaceanu/1dd65a908f00db22cb9f to your computer and use it in GitHub Desktop.
# The classics
class Foo
def bar; end
def self.baz; end
end
Foo.instance_method(:bar).source_location
Foo.method(:baz).source_location
# A tad more
constant = User
$".detect{|load_path|
load_path.include?(constant.to_s.underscore)
}
# Credits
# http://stackoverflow.com/questions/9868649/how-do-i-find-where-a-constant-is-defined-in-ruby
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment