Catch method calls


#1

Hi all,

We were wondering if it’s possible to catch all method calls. I mean a
kind
of ‘hook’ that allow you to do something just before a method is
executed.

Browsing in the mailing list’s archives, we read this thread about this
topic: http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/668.
Anyway,
this thread is pretty old, so we’d like to know if nowadays exists a
mechanism to do that.

Thank you all in advance!


#2

This is a good read, if you want to implement such wrapper.
It’s not old… :slight_smile:

http://tinyurl.com/93yy9

gegroet,
Erik V.


#3

Check out Kernel#set_trace_func. Note it is very slow!

Kent.