# How are methods being excecuted?

**URL:** <https://rubytalk.org/t/how-are-methods-being-excecuted/42758>\
**Category:** ruby-talk\
**Created:** [5 December 2007 10:49 UTC](https://rubytalk.org/t/how-are-methods-being-excecuted/42758 "2007-12-05T10:49:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saladin\_Mundi](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@Saladin\_Mundi](https://rubytalk.org/u/Saladin_Mundi)\
**Post date:** [5 December 2007 10:49 UTC](https://rubytalk.org/t/how-are-methods-being-excecuted/42758/1 "2007-12-05T10:49:41Z")

</div>

Hi everyone,

I'm working on a method which should manipulate the excecution of the  
method body.  
Therefore I need to know, how/where a Ruby method is called and  
how/where the method body is excecuted. Its all done on the C-level of  
Ruby.  
If we have something like:

class z  
&nbsp;&nbsp;def x()  
&nbsp;&nbsp;&nbsp;&nbsp;k = "John"  
&nbsp;&nbsp;&nbsp;&nbsp;puts "Hello #{k}"  
&nbsp;&nbsp;end  
end  
t = z.new.x

I found out, that rb\_call/rb\_funcall have something to do with the  
execution of a method. But they are only calling the internal C-methods.  
So the ID mid from rb\_call(VALUE klass, VALUE recv, ID mid, int argc,  
const VALUE \*argv, int scope) refers C-Methods but not also to my method  
x.

So I don't know how to recognize when my (Ruby) method x is called.  
Additionally I don't know which C-Method really executes (not calls) my  
method x. So which method goes through the method body of x and makes  
the setting of the local variable k and the forwarding of the string  
Hello... to the method puts.

It would be so helpful if someone has got tips for me

thanks in advance

sala

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
