Op 30 jun 2009, om 09:29 heeft Fabian Streitel het volgende geschreven:

> I can only recommend this thread: http://www.ruby-forum.com/topic/190337
> We had a nice discussion there on those kind of DSLish attr setters  
> and
> what would be the best way to implement them

I actually like one of the proposed ways in that topic.
Using a method that is both getter and setter.
I decided to create a attr_accessor_special like this:
   def attr_accessor_special(*syms)
     syms.each do | sym |
       name=sym.to_s
       send(:define_method, name) do | *args |
         value = args[0]
         self.instance_variable_set("@#{name}", value) if value
         self.instance_variable_get("@#{name}")
       end
     end
   end

No way to make a value nil again but I don't think that will be needed  
in my case.

Thank you for your replies!

Kind regards,
Wijnand