# Catch method calls

**URL:** <https://www.ruby-forum.com/t/catch-method-calls/65336>\
**Category:** Ruby\
**Created:** [February 10, 2006, 11:53am UTC](https://www.ruby-forum.com/t/catch-method-calls/65336 "2006-02-10T11:53:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Imobach\_GonzSSSSlez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/bbe5ce/32.png) [@Imobach\_GonzSSSSlez](https://www.ruby-forum.com/u/Imobach_GonzSSSSlez)\
**Post date:** [February 10, 2006, 11:53am UTC](https://www.ruby-forum.com/t/catch-method-calls/65336/1 "2006-02-10T11:53:54Z")

</div>

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](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!

---

<div class="post-metadata">

**Author:** ![Imobach\_GonzSSSSlez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/bbe5ce/32.png) [@Imobach\_GonzSSSSlez](https://www.ruby-forum.com/u/Imobach_GonzSSSSlez)\
**Post date:** [February 10, 2006, 1:03pm UTC](https://www.ruby-forum.com/t/catch-method-calls/65336/2 "2006-02-10T13:03:30Z")

</div>

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

[http://tinyurl.com/93yy9](http://tinyurl.com/93yy9)

gegroet,  
Erik V.

---

<div class="post-metadata">

**Author:** ![Imobach\_GonzSSSSlez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/bbe5ce/32.png) [@Imobach\_GonzSSSSlez](https://www.ruby-forum.com/u/Imobach_GonzSSSSlez)\
**Post date:** [February 10, 2006, 4:03pm UTC](https://www.ruby-forum.com/t/catch-method-calls/65336/3 "2006-02-10T16:03:53Z")

</div>

Check out Kernel#set\_trace\_func. Note it is very slow!

Kent.
