From: Niklas Frykholm Date: 2001-11-17T02:47:27+09:00 Subject: [ruby-talk:25547] Re: Getting a class object from a string containg its name [Lars Christensen] > I need to get a reference to a class object from a string with the name of > the class. I want to do this in a secure way because the string comes from > an external source. I could not find any easy way to convert a string or > symbol to a class reference. I found two approaches though: ... > Did I overlook some easy way to look up a symbol or string in the > namespace of Classes? irb(main):012:0> Object.const_get("String") String But this works only for top-level classes. For Net::HTTP you need to do irb(main):018:0> Object.const_get('Net').const_get('HTTP') Net::HTTP // Niklas