From: 7stud -- Date: 2012-12-03T11:43:05+09:00 Subject: Re: changing superclass Nokan Emiro wrote in post #1087546: > Hi metaprogrammers, > > Does someone know if it's possible to dynamically switch superclass, or > change the ancestor chain on an already existing class? > Sure. class Animal def greet puts "Hi, I'm an Animal." end end class Dog < Animal end Dog.new.greet --output:-- Hi, I'm an Animal. module Stuff def greet puts 'Hello there.' end end new_superclass = Stuff Dog.class_eval("include #{new_superclass}") Dog.new.greet --output:-- Hello there. -- Posted via http://www.ruby-forum.com/.