From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2002-02-01T10:54:18+09:00 Subject: using extend dynamically Let's say I've got the following: module MyMixin def foo puts "MyMixin::foo" end end class MyClass def initialize(mixin) self.extend(mixin) end end obj = MyClass.new(:MyMixin) obj.foo This raises the following error: hierarchy.rb:29:in `extend': wrong argument type MyMixin (expected Module) (TypeError) from hierarchy.rb:29:in `initialize' from hierarchy.rb:33:in `new' from hierarchy.rb:33 So, it doesn't like the 'self.extend(:MyMixin)' Is there any other way of doing this without using some kind of case statement: class MyClass def initialize(mixin) case mixin when "MyMixin" self.extend(MyMixin) ... end end end Phil