From: dohzya Date: 2007-07-25T22:32:20+09:00 Subject: Re: Creating instance variables while looping over a hash Just an example to explain my mind : --- # some representation of your data config = {'config' => {'value1' => 'Something here', 'value2' => 'Something else'}} class A def m config config["config"].each { |key, value| # attr_accessor key (optional) self.class.instance_eval {attr_accessor key.to_s} # @key = value instance_variable_set "@#{key}", value } end end # test a = A.new a.m config p a.value2 --- you can also specify if you want an attribute readable and/or writable -- Etienne Vallette d'Osia