On Thu, 05 Jan 2006 12:28:07 -0000, forest <forest.aa / gmail.com> wrote:

> what is the scope of @run field in the code below.  Is it module static
> ? If not, how module static methods can access it ?
>
> module Test
>   module Unit
>     def self.run=(flag)
>       @run = flag
>     end
>
>     def self.run?
>       @run ||= false
>     end
>   end
> end

Forget about static and all that, and remember that modules are objects  
too. Test::Unit is just a constant, that references the Module instance  
for that module.

Does this make it any clearer?

	Test::Unit.run = 'Hmm...'
	Test::Unit.instance_eval { @run }		# => "Hmm..."

	a = Test::Unit
	a.instance_eval { @run }			# => "Hmm..."

-- 
Ross Bamford - rosco / roscopeco.remove.co.uk