On Wed, Jan 14, 2004 at 09:15:18PM +0900, Gavin Sinclair wrote:
> Two comments:
> 
>  - Couldn't the attr_writers be created within "initialize", making it
>    more obvious?

  def initialize
    klass = class << self; self  end
    [:foo, :bar].each {|m| klass.module_eval{ attr_writer m } }
    yield self
    [:foo=, :bar=].each { |m| klass.send :undef_method, m }
    self
  end
?

>  - I'd prefer the writers be RDoc'ed anyway so I can see which
>    attributes I can set in the initializer.

On second thought me too :) I guess I'd just do 

class A
	attr_reader :foo, :bar

	# use only with A.new { |o| ... }
	attr_writer :foo, :bar

	...
end

since rdoc will use the same description for all the 'attributes'
defined in the same attr_* call.

-- 
 _           _                             
| |__   __ _| |_ ___ _ __ ___   __ _ _ __  
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
	Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

Q:     Why are Unix emulators like your right hand?
A:     They're just pussy substitutes!