Created
March 17, 2010 21:27
-
-
Save floere/335728 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 A | |
def self.inherited inheriter | |
class << inheriter | |
def inherited inheriter | |
Object.const_set inheriter.name.to_sym, self | |
p "Sorry, A can't have grandchildren. You, #{inheriter}, are instead to be of class #{self}." | |
end | |
end | |
end | |
end | |
class B < A | |
def looks_into_the_mirror | |
p "OMG! I have become my parents!" | |
end | |
end | |
class C < B | |
def looks_into_the_mirror | |
p "Ah, it was just a nightmare." | |
end | |
end | |
c = C.new | |
c.looks_into_the_mirror |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment