Sha256: e9d7cf5c3f3468938a4bfb0097cd763a7ac38b8dfc301bd370b792e014fa9c64

Contents?: true

Size: 414 Bytes

Versions: 3

Compression:

Stored size: 414 Bytes

Contents

require 'facet/binding/caller'
class Binding
  # 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.
  #
  #   require 'facet/binding/called'
  #
  #   def tester; p method_name; end
  #   tester  #=> "tester"
  #
  def method_name
    name = /\`([^\']+)\'/.match(caller(1).first)[1]
    return name
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-0.7.0 lib/facet/binding/method_name.rb
facets-0.7.1 lib/facet/binding/method_name.rb
facets-0.7.2 lib/facet/binding/method_name.rb