Sha256: c185b2e8635bbf0adca69cdaacde33435545843f6f0fe2e827e89aa0e2c1a57c

Contents?: true

Size: 618 Bytes

Versions: 6

Compression:

Stored size: 618 Bytes

Contents

module Kernel

  # Easy access to an object qua class, otherwise
  # known as the object's metaclass or singleton class.
  #
  # Yes, another one.

  def qua_class(&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_qua_class
      o = Object.new
      assert_equal( (class << o; self; end), o.qua_class )
    end

  end

=end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
facets-1.8.0 lib/facets/core/kernel/qua_class.rb
facets-1.8.20 lib/facets/core/kernel/qua_class.rb
facets-1.8.49 lib/facets/core/kernel/qua_class.rb
facets-1.8.51 lib/facets/core/kernel/qua_class.rb
facets-1.8.54 lib/facets/core/kernel/qua_class.rb
facets-1.8.8 lib/facets/core/kernel/qua_class.rb