[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to get the name of the executing method?

Griff

3/20/2007 2:15:00 AM

How do I use reflection to get the name of the executing method?

2 Answers

Chris Carter

3/20/2007 2:19:00 AM

0

On 3/19/07, Griff <grettke@gmail.com> wrote:
> How do I use reflection to get the name of the executing method?
>
>
>
ri caller :)

--
Chris Carter
concentrationstudios.com
brynmawrcs.com

Gary Wright

3/20/2007 4:48:00 AM

0


On Mar 19, 2007, at 10:15 PM, Griff wrote:

> How do I use reflection to get the name of the executing method?

There were two methods, __method__ and __callee__ in 1.9 for
that provided this information. __method__ returned the
name used when the method was defined and __callee__ provided
the name used to call the method (i.e., via an alias).

They got lost in the merge of YARV into the 1.9 code base.
I just posted a request to ruby-core to have them added back
in.

If you've got two methods that only differ in how they
interpret their arguments it might be nice to simply use
the name of the alias to select the correct argument
processing rather then having two methods that eventually
make a call to a more generalized third method to do the
work.

Gary Wright