From: nobu.nokada@... Date: 2002-02-01T14:05:04+09:00 Subject: Re: using extend dynamically Hi, At Thu, 31 Jan 2002 19:30:37 -0800, wrote: > What if I had a string that contained the name of a module that I wanted > to extend an object with? (snip) > Is there any way of doing this without resorting to eval? (or case) It doesn't concern #extend at all, however, you can use Module#const_get to get a constant from its name. > obj = MyClass.new(moduleToMix) #this won't work obj = MyClass.new(Object.const_get(moduleToMix)) For nested class: class Module def nested_const(n) if (n = n.split('::')).first.empty? k = ::Object n.shift else k = self end n.each {|n| k = k.const_get(n)} k end end p Object.nested_const("::File::Stat") -- Nobu Nakada