From: Ola Bini Date: 2006-08-29T17:02:10+09:00 Subject: Including a class. Hi, As an extension on my earlier question of partial includes; I just noticed that you can't include a Class, even though it is a Module. Anyone have a way of doing this? What I would like to do, is to be able to dynamically mix in some good methods from preexisting classes, depending on arguments to the constructor. Since I need to do it dynamically, and also need it differently for different instances of the class, I can't make it inherit the other class. What I would like is something like this; say I have class Foo and Bar, with many methods in them. class Baz < AnotherAbstractBaseClass def initialize(config={}) self.singleton_class.module_eval do if config[:foo] partial_include Foo, :method1, :method7 elsif config[:bar] partial_include Bar, :method1, :method7 end end end end Baz.new(:bar => true).method1 But I can't have an instance of Bar or Foo so delegating is impossible. I need the methods to be in the the same instance. Any help? =) -- Ola Bini (http://ola-bini.blogspot.com) JvYAML, RbYAML, JRuby and Jatha contributor System Developer, Karolinska Institutet (http://www.ki.se) OLogix Consulting (http://www.ologix.com) "Yields falsehood when quined" yields falsehood when quined.