Sha256: 89ae80b9093701dcfeebd764c45de296dd92fde3cc30b8450ca68e2053248bf9

Contents?: true

Size: 829 Bytes

Versions: 9

Compression:

Stored size: 829 Bytes

Contents

unless (RUBY_VERSION[0,3] == '1.9')

  module Kernel

    # Retreive the current running method name.
    #
    #   def tester; __method__; end
    #   tester  #=> :tester
    #
    # Technically __callee__ should provided alias names,
    # where __method__ should not. But we'll have to
    # leave that distinction to Ruby 1.9+.

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

    # Retreive the current running method name.
    #
    #   def tester; __callee__; end
    #   tester  #=> :tester
    #
    # Technically __callee__ should provided alias names,
    # where as __method__ should not. But we'll have to
    # leave that distinction to Ruby 1.9+.

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

    private :__callee__, :__method__

  end

end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
facets-2.6.0 lib/core/facets/kernel/__method__.rb
facets-2.4.2 lib/core/facets/kernel/__method__.rb
facets-2.4.3 lib/core/facets/kernel/__method__.rb
facets-2.4.4 lib/core/facets/kernel/__method__.rb
facets-2.4.5 lib/core/facets/kernel/__method__.rb
facets-2.5.0 lib/core/facets/kernel/__method__.rb
facets-2.5.1 lib/core/facets/kernel/__method__.rb
facets-2.5.2 lib/core/facets/kernel/__method__.rb
mack-facets-0.8.2 lib/gems/facets-2.4.5/lib/core/facets/kernel/__method__.rb