Skip to content

Instantly share code, notes, and snippets.

@pjb3
Created March 9, 2011 22:54
Show Gist options
  • Save pjb3/863188 to your computer and use it in GitHub Desktop.
Save pjb3/863188 to your computer and use it in GitHub Desktop.
You can find at runtime where a method was defined. This is a little hack to then open that method in textmate
> m = 2.days.method(:ago)
=> #<Method: Fixnum(ActiveSupport::CoreExtensions::Numeric::Time)#ago>
> m.__file__
=> "/Users/paul/.rvm/gems/ree-1.8.7-2011.03@deals/gems/activesupport-2.3.5/lib/active_support/core_ext/numeric/time.rb"
> m.__line__
=> 64
> class Method; def open_in_textmate; `mate -l #{__line__} #{__file__}`; end; end
=> nil
> 2.days.method(:ago).open_in_textmate
=> ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment