Mehr, Assaph (Assaph) wrote:

>>1) is there any way to do this automatically?
>>    
>>
>
>Not at the moment, but it's easy to implement on your own:
>
>class Module
>  def attr_bool sym
>    attr_reader "#{sym}?"
>    attr_writer sym
>  end
>end
>
>class MyClass
>  attr_bool :foo
>end
>
>p MyClass.instance_methods - Class.methods
>
>
>  
>

This won't work though

x = MyClass.new
x.foo = true
p x.foo? #=> nil

The problem seems to be that the writer is setting the variable @foo but 
the reader is reading the variable @foo?

--
Mark Sparshatt