Sha256: 1d3df9cf011405a796533c486c4f4b672613391353e38657efac2bb838a902dc
Contents?: true
Size: 970 Bytes
Versions: 12
Compression:
Stored size: 970 Bytes
Contents
module Kernel private # Retreive the current running method. # There is a lot of debate on what to call this. # #method_name differs from #called only by the fact # that it returns a string, rather then a symbol. # # def tester; method_name; end # tester #=> "tester" # def methodname name = /\`([^\']+)\'/.match(caller(1).first)[1] return name end # depricate? alias_method :method_name, :methodname end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCKernel < Test::Unit::TestCase def test_method_name # For some reason this was returning a string # even when aliased to #called. Why? # Well, I couldn't seem to fix it, so I just # accepted it as fact and made +method_name+ # purposefully work that way. assert_equal( "test_method_name", method_name ) end end =end
Version data entries
12 entries across 12 versions & 1 rubygems