Trans schrieb:
> Unfortuately when I use this to make a Rake command-line emulator I
> want to use the module at the toplevel and can't.

Tom, I think I still don't get what your problem is. If you want to use 
a module at the toplevel just include it in Object.

The module:

   module M
     def val *args
       if args.empty?
         @val
       else
         @val = args[ 0 ]
       end
     end
   end

I used some instance variables here, because you wrote about them in the 
answer to Matz.

Make it available at the toplevel (and everywhere else):

   class Object
     include M
   end

   p val         # => nil
   val  "main"
   p val         # => "main"

It's also available at the class level:

   class Q
     p val       # => nil
     val "Q"
     p val       # => "Q"
   end

HTH

Regards,
Pit