From: Ch Ba Date: 2009-07-30T04:34:30+09:00 Subject: Dynamically mixins? So I'm trying to figure out how I can allow an end user to decide which modules to mixin to a instance of a class, but I'm not sure if it's possible. An example of what I would like. module Thing @bar = 5 end class Foo def initialize @bar = 0 @foo = 2 end end class FooBar < Foo def initialize(*modules) @bar = 1 modules.each do |module_name| eval("include #{module_name.to_s.capitalize}") end end end test = FooBar.new(:thing) In the previous example, test would be an instance of FooBar, and it's @bar would be 5 (from the module Thing), and it's @foo would be 2, from it's superclass. Is that possible? The previous returns a nomethoderror for "include" in the instance of test. And it might have several other errors since I just typed it up. -- Posted via http://www.ruby-forum.com/.