> MyModule.configure do
>   foo = false
> end

That just creates a block local variable which is destroyed when the 
block ends.  This block:

> MyModule.configure do
>   @foo = false
> end

...gets its bindings from the surrounding scope at the time the block 
executes, and at that time self is 'main' and the 'main' object has no 
method foo=() defined for it.


You could do this:


module MyModule
  class <<self
    attr_accessor :foo

    def configure(hash)
      hash.each {|key, val| send(:"#{key}=", val)}
    end
  end

end

p MyModule.foo
MyModule.configure 'foo' => false
p MyModule.foo

--output:--
nil
false

-- 
Posted via http://www.ruby-forum.com/.