From: Farrel Lifson Date: 2006-09-08T00:21:56+09:00 Subject: Re: Has a method been called? On 07/09/06, aidy wrote: > Hi, > Is it possible to find out if a method has been called except by adding > a flag to it? > > class Whatever > @flag = 0 > > def method_called > @flag += 1 > end > > def has_method_been_called > false > return true if @flag > 0 > end > > end > > Cheers > > Aidy > > > Have a look at set_trace_func. It's documented in the pickaxe book online at http://www.rubycentral.com/book/ospace.html (just scroll down to Tracing Your Program's Execution). You'll probably be interested in the 'call' events. Farrel