Sha256: fa57abce4279c4a2f1c6303dbd9a6bab4ad2babf4f9865f6ffd9b39a53182b9c
Contents?: true
Size: 786 Bytes
Versions: 4
Compression:
Stored size: 786 Bytes
Contents
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 __method__ /\`([^\']+)\'/.match(caller(1).first)[1].to_sym end # Technically this should provided alias names, # where __method__ should not. But we'll have to # leave that distinction to Ruby 1.9+. alias_method :__callee__, :__method__ end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCKernel < Test::Unit::TestCase def test_method_name assert_equal( "test_method_name", __method__.to_s ) end end =end
Version data entries
4 entries across 4 versions & 1 rubygems