Get the name of the currently executing method

Even better than my first answer you can use __method__:

class Foo
  def test_method
    __method__
  end
end

This returns a symbol – for example, :test_method. To return the method name as a string, call __method__.to_s instead.

Note: This requires Ruby 1.8.7.

Leave a Comment