From: Tony Arcieri Date: 2009-04-09T06:01:10+09:00 Subject: Re: Instantiate different class based on variable contents --0016368e1f5e26b4b40467116e06 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On Wed, Apr 8, 2009 at 2:40 PM, stephen O'D wrote: > dispatch = { > 'Foo' => Foo, > 'Bar' => Bar > } > > obj = dispatch[var].new(...) > > Is there another Ruby way to do this sort of thing? > Object.const_get(var).new(...) or with ActiveSupport: var.constantize.new(...) -- Tony Arcieri medioh.com --0016368e1f5e26b4b40467116e06--