video = Video.first
save_method = video.method(:save)
save_method.class
# => Method
save_method.source_location
# => an Array with [file, line]
save_method.source
# => String
save_method.source.display
# => String, with line breaks evaluated
save_method.super_method
# => another Method, or nil
# print a method's source & location
# recurse into super definitions if they exist
def show_method(method)
if method.super_method
show_method(method.super_method)
end
puts method.source_location.inspect
puts method.source.display
puts
end
video = Video.first
show_method(video.method(:save))
$ bundle show activerecord
$ bundle open activerecord