From: Robert Klemme Date: 2009-03-21T01:22:23+09:00 Subject: Re: Tracing method definition in core and stdlibs? On 20.03.2009 13:56, John Wells wrote: > I'm interested in tracing method definition in core and stdlibs. > However, I'm not sure how to hook in the process at such an early > stage. > > For example, if I put the following code in trace.rb: > > [Class, Module].each do |n| > n.class_eval do |clz| > def method_added(x) > puts "Method==#{x}" > end > end > end > > > And then call > > $ ruby -rtrace.rb -e 'puts "test"' > > I only see two "Method==" outputted...both "Method==method_added", and > both obviously in response to this code itself. > > Is there a way to hook in earlier? Probably not as many methods of the standard library are define in C code and I doubt that will trigger a method_added. Btw, what do you need that for? Cheers robert