
require 'facets/more/functor.rb'

module Kernel #class Object

  # Returns a Functor that allows one to call any
  # Kernel or Object method bound to self, making it
  # possible to bypass overrides of Kernel and Object
  # methods.
  #
  #   class A
  #     def object_id ; "OBTUSE" ; end
  #   end
  #
  #   c = C.new
  #   c.object_id             #=> "OBTUSE"
  #   c.__self__.object_id    #=> 6664875832
  #
  #--
  # Might this be better named as 'object' or '__object__'?
  # Should this method actually be private?
  #++

  def __self__
    @__self__ ||= Functor.new do |meth, *args|  # &blk|
      Object.instance_method(meth).bind(self).call(*args) # ,&blk)
    end
  end

  #alias_method :self, :__self__

end
