> How is an 'include' outside of a module different from one inside a
> module. Where does the outer 'include' come from (the only documented
> include method is on Module).
>
> The following code works:
>
> require 'fox'
> include Fox
> module MyModule
>   class MyClass
>     def hello; puts FXTreeList; end
>   end
> end
>
> The following does not:
> module MyModule
>   require 'fox'
>   include Fox
>   class MyClass
>     def hello; puts FXTreeList; end
>   end
> end
>
> I was under the impression that part of the mechanism of include was to
> include the constants defined in the other module.

Yes. The first example includes Fox in Object, hence making its constants
visible to all objects. The second example includes it in MyModule, not in
MyClass, so its constants become directly visible to MyModule, not to
MyClass. So the following does work:

  module MyModule
    require 'fox'
    class MyClass
      include Fox
      def hello; puts FXTreeList; end
    end
  end

Or this does, but then instead of Fox::FXTreeList, you'd need to type the
longer MyModule::FXTreeList :

  module MyModule
    require 'fox'
    include Fox
    class MyClass
      def hello; puts MyModule::FXTreeList; end
    end
  end


Peter