From: Daniel Schierbeck Date: 2006-06-15T19:44:17+09:00 Subject: Re: convert Joakim Oman wrote: > Hello > > I wonder if there is a simple way to convert all keys in a Hash to > member variables in a Class without knowing the key names in the Hash > beforehand. vars = {:foo => 101, :bar => 42, :baz => 1337} vars.each do |name, value| SomeClass.instance_variable_set("@#{name}", value) end You could also use an OpenStruct. Cheers, Daniel