Is it possible to reflect the text of a dynamically generated method
definition?
I’m debugging some ActiveRecord code and it would be very helpful to
dump the text of some of the generated methods. For example, say I
have this:
class Foo < ActiveRecord::Base
has_one :bar
end
AR associations generates a whole host of methods, Foo#bar,
Foo#create_bar, etc., and the exact definitions depend on the options
that I passed to has_one. I can walk through associations.rb and
friends to reconstruct what I think the methods look like but that is
slow and error prone.
There must be an easier way, this is Ruby after all!