instance method parent

Ruby on Rails 2.2.3

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

parent()

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

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

p M::N.parent # => M
p X.parent    # => M

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

p M.parent          # => Object
p Module.new.parent # => Object
Source
# File activesupport/lib/active_support/core_ext/module/introspection.rb, line 30
      def parent
        parent_name ? parent_name.constantize : Object
      end

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

Defined in ActiveSupport::CoreExtensions::Module

Type at least 2 characters to search.

↑↓ navigate · open · esc close