From: Hal Fulton Date: 2004-04-07T06:26:53+09:00 Subject: Re: object.@attribute George Ogata wrote: > Jason Voegele writes: > > >>2) You might want to use a standard attr_writer generated writer method, but >>provide a custom reader method. I do this all of the time with boolean >>attributes, so I can add the '?' to the end of the reader method. > > > I've hit this before too. Maybe attr_accessor(:foo?) should define > 'foo?' and 'foo=' (instead of the current 'foo?' and 'foo?=')? > > Or maybe this syntax should be allowed: > > obj.foo? = true > > Hmm? FWIW, I've considered an attr_query that created foo= and foo? methods. Yesterday I also considered attr_proc that would construct methods like this: obj.doit = proc { do_stuff } # set the callback obj.doit # call it! Of course, this sort of thing is easily doable in Ruby, so I don't see a core change as appropriate unless this became widespread. Hal