How to get the name of the executing method?

Discussion in 'Ruby' started by Griff, Mar 20, 2007.

  1. Griff

    Griff Guest

    How do I use reflection to get the name of the executing method?
     
    Griff, Mar 20, 2007
    #1
    1. Advertising

  2. Griff

    Chris Carter Guest

    On 3/19/07, Griff <> wrote:
    > How do I use reflection to get the name of the executing method?
    >
    >
    >

    ri caller :)

    --
    Chris Carter
    concentrationstudios.com
    brynmawrcs.com
     
    Chris Carter, Mar 20, 2007
    #2
    1. Advertising

  3. Griff

    Gary Wright Guest

    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
     
    Gary Wright, Mar 20, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Gaynor
    Replies:
    3
    Views:
    2,436
  2. =?iso-8859-1?B?bW9vcJk=?=
    Replies:
    7
    Views:
    891
    Roedy Green
    Jan 2, 2006
  3. ding feng
    Replies:
    2
    Views:
    2,907
    ding feng
    Jun 25, 2003
  4. Bobby Chamness
    Replies:
    2
    Views:
    2,441
    Joe Smith
    Apr 22, 2007
  5. Ezra Zygmuntowicz
    Replies:
    2
    Views:
    125
    Ezra Zygmuntowicz
    Jul 10, 2006
Loading...

Share This Page