Method: String#root_module

Defined in:
lib/chemlab/core_ext/string/root_module.rb

#root_moduleModule

Find the root module (parent module) of a class or module

Examples:

'A::B::C'.root_module #=> A
'A::B'.root_module => A

Returns:

  • (Module)

    the root module



10
11
12
# File 'lib/chemlab/core_ext/string/root_module.rb', line 10

def root_module
  Object.const_get(split('::').first)
end