From: Robert Klemme Date: 2004-12-10T21:27:25+09:00 Subject: Re: adding object attributes "David A. Black" schrieb im Newsbeitrag news:Pine.LNX.4.61.0412100332320.5050@wobblini... > What you want to do is use attr_accessor -- but, as you say, not in > 'A', but rather in the singleton class of 'b'. You would do this like > this: Alternatively Artur can use OpenStruct, where you can add attributes even more dynamic: :25:55 [source]: irbs -r ostruct >> a = OpenStruct.new([:a]) => >> a.a => nil >> a.dummy = "hello world" => "hello world" >> a.dummy => "hello world" You can even inherity OpenStruct, if you want to add additional methods: >> class A < OpenStruct >> def my_method() puts "buh!" end >> end => nil >> a=A.new => >> a=A.new [:a] => >> a.my_method buh! => nil >> a.dummy = "hello" => "hello" >> a.dummy => "hello" >> a => Or you use a hash - that might be appropriate in some circumstances, too. Kind regards robert