
require 'facets/core/binding/caller'

class Binding

  # Retreive the current running method.
  #
  #   def tester; p called; end
  #   tester  #=> :tester
  #
  def called
    name = /\`([^\']+)\'/.match(caller(1).first)[1]
    return name.to_sym
  end

end



#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TCBinding < Test::Unit::TestCase

    def setup
      @bind = binding
    end

    def test_called
      assert_equal( :setup, @bind.called )
    end

  end

=end
