From: Joel VanderWerf Date: 2005-07-23T09:14:34+09:00 Subject: Re: Class Attributes and rdoc/Observable Hadmut Danisch wrote: > Hi, > > two questions or proposals about class attributes: Do you really mean "class attributes", or "class methods which define attributes of instances" ? From your questions, it sounds like the latter. > - If the access methods for a class variable are defined with > attr_accessor, rdoc shows them as [RW] in the attributes list. > > But when the access method is explicitely defined with def, > then rdoc does not show it as attribute access, but as an > instance function. > > Sometimes it would be nice to explicitely write the > attr= or attr methods (e.g. to do some checks or give default > values), but to have it listed in the documentation as a > plain attribute. > > Is there a way to make rdoc recognize methods as attribute > methods? > > If not, I'd propose a #:attr: flag. There was some discussion of that recently: http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/147750?147700-148826 > - Is it possible to make attr_writer and attr_accessor notify > Observers if the value changes? If not, I'd propose to > define versions that do so. There's my implementation of that idea at: http://raa.ruby-lang.org/project/observable/ > If I do understand ruby correctly, then this would mean to > add new functions like oattr_writer to the Module class. My version defines an Observable module that you can extend your class with.