On Wednesday, January 14, 2004, 7:15:58 PM, Mauricio wrote: >> The only downside is that it requires you to set *accessors* instead of >> the more restrictive *readers*. > Credits go to Hal Fulton > batsman@tux-chan:/tmp$ expand -t2 a.rb > class A > attr_reader :foo, :bar > # only for initialize! :nodoc: or something for rdoc > attr_writer :foo, :bar > def initialize > yield self > klass = class << self; self end > ["foo=", "bar="].each { |m| klass.send :undef_method, m } > self > end > end Two comments: - Couldn't the attr_writers be created within "initialize", making it more obvious? - I'd prefer the writers be RDoc'ed anyway so I can see which attributes I can set in the initializer. Gavin