Sha256: f9b52071e30560b0715f3622951eedfc08deed41f02bb32e92e3b63c2e7199cc

Contents?: true

Size: 435 Bytes

Versions: 3

Compression:

Stored size: 435 Bytes

Contents

module Kernel
  # Retreive the current running method.
  # There is a lot of debate on what to call this.
  # #called differs from #method_name only by the fact
  # that it returns a symbol, rather then a string.
  #
  #   require 'facet/main/called'
  #
  #   def tester; p called; end
  #   tester  #=> :tester
  #
  def called
    name = /\`([^\']+)\'/.match(caller(1).first)[1]
    return name.to_sym
  end
  private :called
end


Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-0.7.0 lib/facet/kernel/called.rb
facets-0.7.1 lib/facet/kernel/called.rb
facets-0.7.2 lib/facet/kernel/called.rb