public
Created

View Source for Ruby

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# Toss this in your ~/.irbrc file for a convenient way
# to peruse Ruby source code in TextMate. This
# only works in Ruby 1.9!
#
# Use it in irb like so:
#
# >> require 'active_record'
# >> ActiveRecord::Base.source_for_method(:create)
 
class Object
def source_for_method(method)
location = self.method(method).source_location
`mate #{location[0]} -l #{location[1]}` if location
location
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.