Sha256: c1d38d20b910ccb13186d680009a53fe7a4337d4e281186c5526b9a5114d6f15

Contents?: true

Size: 665 Bytes

Versions: 7

Compression:

Stored size: 665 Bytes

Contents

module Kernel

  # Easy access to an object qua class, otherwise
  # known as the object's metaclass or singleton class.
  #
  #     It is what it is.
  #
  #               -- transonoma

  def quaclass( &block )
    (class << self; self; end).module_eval(&block) if block
    (class << self; self; end)
  end
  alias_method :__quaclass__, :quaclass

end


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

  require 'test/unit'

  class TCKernel < Test::Unit::TestCase

    def test_singleton
      o = Object.new
      assert_equal( (class << o; self; end), o.quaclass )
    end

  end

=end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
facets-1.4.3 lib/facets/core/kernel/quaclass.rb
facets-1.4.4 lib/facets/core/kernel/quaclass.rb
facets-1.4.5 lib/facets/core/kernel/quaclass.rb
facets-1.7.0 lib/facets/core/kernel/quaclass.rb
facets-1.7.30 lib/facets/core/kernel/quaclass.rb
facets-1.7.38 lib/facets/core/kernel/quaclass.rb
facets-1.7.46 lib/facets/core/kernel/quaclass.rb