Method: Module#module_parent

Defined in:
activesupport/lib/active_support/core_ext/module/introspection.rb

#module_parentObject

Returns the module which contains this one according to its name.

module M
  module N
  end
end
X = M::N

M::N.module_parent # => M
X.module_parent    # => M

The parent of top-level and anonymous modules is Object.

M.module_parent          # => Object
Module.new.module_parent # => Object


34
35
36
# File 'activesupport/lib/active_support/core_ext/module/introspection.rb', line 34

def module_parent
  module_parent_name ? ActiveSupport::Inflector.constantize(module_parent_name) : Object
end