Duplicate: How To Find Where A Ruby Method Is Defined At Runtime
With a given object, is it possible to find out where each method was defined?
After the fact, it will be pretty tough, but you can use a hook method to observe the line numbers where a method is defined.
class X < Object
def X.method_added(symbol)
puts "adding method #{symbol} to class X from #{caller(0)"
end
end
class X
def a_method
end
end