From: Mark Volkmann Date: 2006-05-31T22:41:59+09:00 Subject: Re: class from string On 5/31/06, Gregory Seidman wrote: > On Wed, May 31, 2006 at 09:54:07AM +0900, Ryan Leavengood wrote: > } On 5/30/06, Dan Kirkwood wrote: > } >Is there a better way to get to a class when you have the class name in > } >a string? > } > } This really gets asked a whole lot, especially from Ruby Forum. I > } really, really, really wish there was a prominent FAQ on Ruby Forum > } with this as like question number 1. This would save people like Dan > } from having to ask the question and would save the rest of us from > } having to answer it for the 50th time. > > The problem with a simple FAQ is that the obvious answer (Object.const_get) > doesn't handle qualified classes (e.g. Foo::Bar) and the more complicated > version usually given in response only handles fully-qualified classes. I > decided to write a definitive version that handles fully- and > partially-qualified class names, but it isn't trivial. Honestly, it should > probably be part of Ruby's core. Agreed! Has there already been a formal request to add this in 1.9? > See http://redcorundum.blogspot.com/2006/05/kernelqualifiedconstget.html -- R. Mark Volkmann Object Computing, Inc.