instance method module_parent

Ruby on Rails edge

Since v6.0.6.1

Available in: v6.0.6.1 v6.1.7.10 v7.0.10 v7.1.6 v7.2.4 v8.0.5.1 v8.1.4 edge

Signature

module_parent()

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 “`

Source
# File activesupport/lib/active_support/core_ext/module/introspection.rb, line 44
  def module_parent
    module_parent_name ? ActiveSupport::Inflector.constantize(module_parent_name) : Object
  end

Defined in activesupport/lib/active_support/core_ext/module/introspection.rb line 44 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Module

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close