Sha256: 1fb215abb9e886739947e64a626c933eef85bc54e9a8b1a85f6bcfb21013131c

Contents?: true

Size: 784 Bytes

Versions: 20

Compression:

Stored size: 784 Bytes

Contents

class Object

  # Easy access to an object's "special" class,
  # otherwise known as it's meta class or singleton class.
  #
  def metaclass
    (class << self; self; end)
  end
  #warn 'metaclass is being depricated. Use #own or #singleton.'

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 )
      #assert_nothing_raised do
      #  o.metaclass_eval{ @@a = "test" }
      #end
      #assert_nothing_raised do
      #  o.define_metaclass_method(:testing){ |x| x + 1 }
      #end
      #assert_equal(2, o.testing(1) )
    end

  end

=end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
facets-1.0.3 packages/core/lib/facet/kernel/metaclass.rb
facets-0.9.0 lib/nano/kernel/metaclass.rb
facets-1.0.0 lib/facet/kernel/metaclass.rb
facets-1.3.0 lib/facets/core/kernel/metaclass.rb
facets-1.1.0 lib/facet/kernel/metaclass.rb
facets-1.2.0 lib/facets/core/kernel/metaclass.rb
facets-1.2.1 lib/facets/core/kernel/metaclass.rb
facets-1.3.2 lib/facets/core/kernel/metaclass.rb
facets-1.3.1 lib/facets/core/kernel/metaclass.rb
facets-1.3.3 lib/facets/core/kernel/metaclass.rb
facets-1.4.2 lib/facets/core/kernel/metaclass.rb
facets-1.4.0 lib/facets/core/kernel/metaclass.rb
facets-1.4.1 lib/facets/core/kernel/metaclass.rb
facets-1.4.3 lib/facets/core/kernel/metaclass.rb
facets-1.4.4 lib/facets/core/kernel/metaclass.rb
facets-1.4.5 lib/facets/core/kernel/metaclass.rb
facets-1.7.38 lib/facets/core/kernel/metaclass.rb
facets-1.7.0 lib/facets/core/kernel/metaclass.rb
facets-1.7.30 lib/facets/core/kernel/metaclass.rb
facets-1.7.46 lib/facets/core/kernel/metaclass.rb