parents()
public
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
p M.parents
p M::N.parents
p X.parents
# File activesupport/lib/active_support/core_ext/module/introspection.rb, line 36
def parents
parents = []
parts = name.split('::')[0..-2]
until parts.empty?
parents << (parts * '::').constantize
parts.pop
end
parents << Object unless parents.include? Object
parents
end