From: Richard Date: 2006-12-02T13:20:10+09:00 Subject: Re: Is there a simply way to get every method log itself before running? Hi Bill, Thanks for responding. > Since you mentioned Rails, I'll assume you're using it. You're right on :-) > ActionController::Filters::ClassMethods ... after_filter I've used the before_filter, but I never noticed the after_filter, so it's nice to learn about it. Hope, as a Rails newbie, I'd like to trace through every method invoked in a simple Rails app and display "interesting" things, e.g. the arguments it received and the the value it returned. But I want to make that happen in an automated way, e.g. inject my debug routines at the entry and exit points, which is what Aspect-Oriented Program is to make easy to accomplish. I've had some help in getting set_trace_func working, but I haven't figured out yet whether that will do what I want. And I've looked at Needle but haven't gotten Dependency Injection even coded yet. The holy grail for me is automated temporary transform of my Rails app. Is there a way that an after_filter could be specified at the top level of a Rails app and have it operate on all the subordinate methods? Regards, Richard bill walton wrote: > Hi Richard, > > Richard wrote: > > I'd like to write a trace function and have every method > > execute that trace when the method's invoked. In that > > trace function, I'd like to be able, e.g. to write the > > invoked method's name, perhaps more. > > > > Is there an easy way to do that? > > > > BTW, I posted this question on the Ruby/Rails Newsgroup > > before Irealized it's more appropriate here. > > Since you mentioned Rails, I'll assume you're using it. If not, this > won't apply. > > Check out the Class documentation ( http://api.rubyonrails.org , left > panel, middle section) for ActionController::Filters::ClassMethods. > You're probably looking for an after_filter given that you may want to > store some stuff you 'compute' in the method. > > hth, > Bill