instance method
module_parents
Ruby on Rails 7.0.10
Since v6.0.6Signature
module_parents()
Returns all the parents of this module according to its name, ordered from nested outwards. The receiver is not contained within the result.
module M module N end end X = M::N M.module_parents # => [Object] M::N.module_parents # => [M, Object] X.module_parents # => [M, Object]
Source
# File activesupport/lib/active_support/core_ext/module/introspection.rb, line 51
def module_parents
parents = []
if module_parent_name
parts = module_parent_name.split("::")
until parts.empty?
parents << ActiveSupport::Inflector.constantize(parts * "::")
parts.pop
end
end
parents << Object unless parents.include? Object
parents
end
Defined in activesupport/lib/active_support/core_ext/module/introspection.rb line 51
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Module