Skip to content

Instantly share code, notes, and snippets.

@floere
Created March 17, 2010 21:27
Show Gist options
  • Save floere/335728 to your computer and use it in GitHub Desktop.
Save floere/335728 to your computer and use it in GitHub Desktop.
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