7stud -- wrote in post #1077677:
>> MyModule.configure do
>>   foo = false
>> end
>
> That just creates a block local variable which is destroyed when the
> block ends.

Is there a way to make things in the block execute as if they were being 
called on MyModule, i.e.

MyModule.foo = 1
MyModule.bar = 2

could be alternatively:

MyModule.do
  foo = 1
  bar = 2
end

> 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

That is helpful, but I have a way to do a hash easily already via 
another method, with the idea that the following might be interesting:

MyModule.do
  foo = 1
  def bar
    2 # imagine a more interesting and dynamic result
  end
end

I understand it might require some changes, so syntax might not be 
exactly like that, but originally I thought this would be doable, and am 
just kind of stuck. Ilia had suggested ActiveSupport::Configurable on 
the list but it requires config to be sent in as a parameter and I was 
hoping to allow method definition and not have to specify the 
config.varname = ...

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