From: "Iñaki Baz Castillo" Date: 2008-04-23T22:11:18+09:00 Subject: Re: Is possible to extend "attr_accessor" "attribue=" method? 2008/4/23, Trans : > On Apr 23, 4:49 am, "Iñaki Baz Castillo" wrote: > > Hi, I'd like to use an "attr_accessor" but when its attribute is > > modified it should be executed more code than just an assignament. > > I handle it in this way (not cool): > > > > class MyClass1 < Father > > > > def self.attr_accessor(name) > module_eval %{ > > attr_reader :#{name} > > > > def #{name}= (value) > > @#{name} = value > > > @modified = true > > ...more code... > > end > } > end > > > > end It's really cool !!!! Just an issue: the above code don't allow multiple attributes definition: attr_accessor :atr, atr2 => `attr_accessor': wrong number of arguments (2 for 1) (ArgumentError) I don't remember now what must I do to take all the possible arguments as an array, could you point it to me please? thanks a lot. -- Iñaki Baz Castillo