Sha256: 830db3895c89d3fa1ef6cbc1e06d627e7fd3e18148e8bee91d8618510254979f

Contents?: true

Size: 1005 Bytes

Versions: 7

Compression:

Stored size: 1005 Bytes

Contents

module Kernel

  unless defined?(__method__) == "method"  # 1.8.7+

    # Retreive the current running method name.
    #
    #   def method_example
    #     __method__
    #   end
    #
    #   method_example  #=> :method_example
    #
    # 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

    private :__method__

  end

  unless defined?(__callee__) == "method"  # 1.9+

    # Retreive the current running method name.
    #
    #   def callee_example
    #     __callee__
    #   end
    #
    #   callee_example  #=> :callee_example
    #
    # 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__

  end

end

Version data entries

7 entries across 6 versions & 1 rubygems

Version Path
facets-2.9.3 lib/core/facets/kernel/__method__.rb
facets-2.9.2 src/core/facets/kernel/__method__.rb
facets-2.9.2 lib/core/facets/kernel/__method__.rb
facets-2.9.1 lib/core/facets/kernel/__method__.rb
facets-2.9.0 lib/core/facets/kernel/__method__.rb
facets-2.9.0.pre.2 lib/core/facets/kernel/__method__.rb
facets-2.9.0.pre.1 lib/core/facets/kernel/__method__.rb