From: Brian Candler Date: 2007-03-14T05:57:08+09:00 Subject: Re: YAML and ruby classes On Wed, Mar 14, 2007 at 01:25:06AM +0900, Matteo Cavalleri wrote: > Stefano Crocco wrote: > > > name.split('::').inject(Object){|res, c| c.const_get(c)}.new h > > this is pretty complicated for my current knowledge of ruby :D the > method suggested by ken bloom works and is simpler for me, but thanks > anyway for you help! :) To get at Foo::Bar::Baz you need to do klass = Object.const_get("Foo").const_get("Bar").const_get("Baz") So that one-liner above is really another way of writing: name = "Foo::Bar::Baz" names = name.split("::") klass = Object while n = names.shift klass = klass.const_get(n) end