From: Austin Ziegler Date: 2005-06-24T12:19:47+09:00 Subject: Re: string to Class object On 6/23/05, Hal Fulton wrote: > Austin Ziegler wrote: > > For nested values, it's: > > > > name = 'Transaction::Simple::Group' > > klass = name.split(/::/).inject(Object) { |k, n| k.const_get(n) } > > p klass # => Transaction::Simple::Group > Quite right. There is also the eval (evil?) method: > > clazz = eval(name) > BTW, I've wondered why Object.const_get doesn't honor > the X::Y::Z form. It's unambiguous and I can't see a > good reason not to decipher it. RCR? -austin -- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca