instance method module_parent

Ruby on Rails 8.0.4

Since v6.0.6

Available in: v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

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 37
  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 37 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Module

Type at least 2 characters to search.

↑↓ navigate · open · esc close