Skip to content

Instantly share code, notes, and snippets.

@mingliangfeng
Last active December 17, 2015 22:39
Show Gist options
  • Save mingliangfeng/5683419 to your computer and use it in GitHub Desktop.
Save mingliangfeng/5683419 to your computer and use it in GitHub Desktop.
show source files of a class or method
find_source = lambda do |clazz, include_super=false|
files = clazz.methods(include_super).inject([]) {|c, m| c << clazz.method(m).source_location.first if clazz.method(m) and clazz.method(m).source_location; c }
files.uniq
end
puts find_source.call(Rails)
puts self.method(:get).source_location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment