On Thu, Jan 05, 2012 at 05:36:02PM +0000, Ben Hughes wrote:
> It will work, just declare the module in Gem A:
 
> module Foo
>   module Bar
>     class Stuff; end
>   end
> end
> 
> If another (Gem B) you can do the same thing:
> 
> module Foo
>   module Bar
>     class Things; end
>   end
> end

Thanks. :)  It looks like the only thing to worry about is whether someone else
goes and defines "Foo" as a class, since a namespace can only be either a
module or a class.

    http://www.martinicity.net/articles/2006/07/15/ruby-namespace-conflicts

The other issue I had to resolve was whether the Ruby C API function
rb_define_module could be invoked more than once with the same module name.
Dunno if it's documented anywhere, but that's the behavior when I snoop the
source code in class.c:

    if (rb_const_defined(rb_cObject, id)) {
        module = rb_const_get(rb_cObject, id);
        if (TYPE(module) == T_MODULE)
            return module;
        rb_raise(rb_eTypeError, "%s is not a module", rb_obj_classname(module));
    }    

(We're actually going to be creating a C extension.)

Marvin Humphrey

-- 
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby

Reply via email to