Project

General

Profile

Feature #12317

Name space of a module

Added by sawa (Tsuyoshi Sawada) over 4 years ago. Updated about 4 years ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:76043]

Description

I want a method to return the name space of a module, something like:

class A; module B; module C end end end

A::B::C.namespace => [A, A::B, A::B::C]

There is nesting method that is similar, but that only returns the lexical nesting information.

There are also some known hacks for this, converting the module to the string representation using to_s or name, and then splitting it by ::. But that easily breaks if the module is anonymous, or is a singleton module. I would like a more robust, core method.

Also available in: Atom PDF