I
Intransition
What would you call a method that did this:
Foo::Bar::Baz.some_method #=> Foo::Bar
Foo::Bar::Baz.some_method #=> Foo::Bar
(+1)Module#enclosing_module ??
I'll vote for parent_namespace.
Module#enclosing_module ??
Module#enclosing_module ??
I prefer #enclosing_module since the "namespace" is a Module.
But how would you implement that? (Except using the name of course)
Foo::Bar could be class. Does that make a difference?
But a class is a module, right? Although more exactly one could argue
that an instance of a class is a module. Well for me that was good
enough an approximation.
As a side note I never use class_eval, but always module_eval.
However if some do not see a class as a (kind of a) module the name
would be chosen badly indeed.
Your right it is, and that should suffice, though I recall matz once
talking about the possibility of Module not being a subclass of Class
in Ruby 2.
Just the same, perhaps we can simplify it to just #enclosure ?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.