
class Object

  # Easy access to an object's "special" class,
  # otherwise known as it's metaclass or singleton class.

  def metaclass(&block)
    if block_given?
      (class << self; self; end).class_eval(&block)
    else
      (class << self; self; end)
    end
  end

end



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

  require 'test/unit'

  class TCKernel < Test::Unit::TestCase

    def test_metaclass
      o = Object.new
      assert_equal( (class << o; self; end), o.metaclass )
    end

  end

=end
