Project

General

Profile

Actions

Feature #12317

open

Name space of a module

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

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:75182]

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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0