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