
module Kernel

  private

  # Retreive the current running method name.
  #
  # There is a lot of debate on what to call this.
  # #me returns a symbol, not a string.
  #
  #   def tester; __method__; end
  #   tester  #=> :tester

  def callee
    /\`([^\']+)\'/.match(caller(1).first)[1].to_sym
  end

  # Technically __callee__ should provided alias names,
  # where __method__ should not. But we'll have to
  # leave that distinction to Ruby 1.9+.

  alias_method :__callee__, :callee
  alias_method :__method__, :callee

end


#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TCKernel < Test::Unit::TestCase

    def test_method_name
      assert_equal( "test_method_name", callee.to_s )
    end

  end

=end