From: Avi Bryant Date: 2001-03-31T18:34:46+09:00 Subject: [ruby-talk:13382] Re: Is there any way to get the current ruby method within in C? On Sat, 31 Mar 2001, Matthew D. Spencer wrote: > Hi, > > I'm rather new to Ruby (*very* new actually), and I'm playing around > with extending it in C. I would like to use the same C function to > handle multiple methods for a given class, but to perform slightly > different (potentially a lot different) behavior based on what method > was called. > > My question is this: is there some way of knowing the method (by name > or unique id) when inside the C code? > > For example: > > VALUE methodHandler(VALUE self, VALUE arg1) { > > ID id = rb_current_method_id(...)? > > ... > } Yup: VALUE methodHandler(VALUE self, VALUE arg1) { ID id = rb_frame_last_func(); ... } Cheers. Avi