Mark J.Reed wrote:
> James Edward Gray II <james / grayproductions.net> writes:
> 
> 
>>On Dec 9, 2005, at 4:57 AM, Ross Bamford wrote:
> 
> 
>>>2) I like documentation. So far, Rdoc is great, but I wonder about  
>>>the following case:
>>>
>>>	class SomeClass
>>>	  attr_accessor :someattr
>>>
>>>	  # But I need to validate, for example, so ...
>>>	  def someattr=(i)
>>>	    @someattr unless i < 10
>>>	  end
>>>	end
> 
> 
> Don't use attr_accessor, then.    attr_accessor doesn't do any magic; it's
> just a shorthand that defines default accessor methods.
> This line:
> 
>         attr_accessor :foo
> 
> has identical results to this code:
> 
>         def foo
>             @foo
>         end
> 
>         def foo=(new_foo)
>             @foo = new_foo
>         end
> 

Almost.  The rdoc output is different.  Using attr_accessor, rdoc does 
not document 'foo' as being a method, but as being an attribute.

Unless you both  use attr_accessor *and* define method bodies.  Then 
rdoc does both; foo is documented as both an attribute and a method.

James
-- 

http://www.ruby-doc.org       - Ruby Help & Documentation
http://www.artima.com/rubycs/ - Ruby Code & Style: Writers wanted
http://www.rubystuff.com      - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com     - Playing with Better Toys
http://www.30secondrule.com   - Building Better Tools