class Module
def parent
M.parent # => Object
The parent of top-level and anonymous modules is Object.
X.parent # => M
M::N.parent # => M
X = M::N
end
end
module N
module M
Returns the module which contains this one according to its name.
def parent parent_name ? ActiveSupport::Inflector.constantize(parent_name) : Object end