From: Markus Hohenhaus Date: 2007-05-10T04:23:57+09:00 Subject: using dynamic method calling with attr_writer methods I'm a total Ruby newbie looking for help. I'm writing an application where I need to dynamical assign object variables via attr_writer object methods. My code is something like this: class Test < ParentClass attr_reader :one, :two, :three attr_writer :one, :two, :three def initialize super end end ( I know I could use attr_accessor but for testing I'll stick to attr_writer and _reader) Now I try to call the 'Test' methods dynamical witch 'object.send' from within my main application: [...] @methods = ['one', 'two', 'three'] test = Test.new @methods.each { |a| test.send(a, 'foo') } [...] This throws the error: ArgumentError: wrong number of Arguments (1 for 0) As far as I understand, this is the correct behaviour. Because without the second argument, the method call returns the value of the class variable. So I believe, that this should work if i'll write all the setter and getter methods myself (which I don't want to, because I'm using a lot of variables). Are there any other methods I can use to dynamically call attr_writer methods to assign values to the class variables or did I get something wrong and made a mistake? -- Posted via http://www.ruby-forum.com/.