Created
May 29, 2009 20:26
-
-
Save rue/120196 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Class | |
protected :instance_type | |
def initialize(sclass=Object) | |
unless sclass.kind_of?(Class) | |
raise TypeError, "superclass must be a Class (#{sclass.class} given)" | |
end | |
set_superclass sclass | |
mc = self.metaclass | |
mc.set_superclass sclass.metaclass | |
super() | |
# add class to sclass's subclass list, for ObjectSpace.each_object(Class) | |
# NOTE: This is non-standard; Ruby does not normally track subclasses | |
sclass.__send__ :add_subclass, self | |
sclass.__send__ :inherited, self | |
end | |
# ... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment