From 004fda35688015350eef6152d0c5dbfa3f26a713 Mon Sep 17 00:00:00 2001
From: Gannon McGibbon <gannon.mcgibbon@gmail.com>
Date: Tue, 2 Oct 2018 12:51:35 -0400
Subject: Prefix Module#parent, Module#parents, and Module#parent_name with
 module

---
 .../core_ext/module/introspection.rb               | 50 ++++++++++++++++------
 1 file changed, 37 insertions(+), 13 deletions(-)

(limited to 'activesupport/lib')

diff --git a/activesupport/lib/active_support/core_ext/module/introspection.rb b/activesupport/lib/active_support/core_ext/module/introspection.rb
index c5bb598bd1..9b6df40596 100644
--- a/activesupport/lib/active_support/core_ext/module/introspection.rb
+++ b/activesupport/lib/active_support/core_ext/module/introspection.rb
@@ -5,8 +5,8 @@ require "active_support/inflector"
 class Module
   # Returns the name of the module containing this one.
   #
-  #   M::N.parent_name # => "M"
-  def parent_name
+  #   M::N.module_parent_name # => "M"
+  def module_parent_name
     if defined?(@parent_name)
       @parent_name
     else
@@ -16,6 +16,14 @@ class Module
     end
   end
 
+  def parent_name
+    ActiveSupport::Deprecation.warn(<<-MSG.squish)
+      `Module#parent_name` has been renamed to `module_parent_name`.
+      `parent_name` is deprecated and will be removed in Rails 6.1.
+    MSG
+    module_parent_name
+  end
+
   # Returns the module which contains this one according to its name.
   #
   #   module M
@@ -24,15 +32,23 @@ class Module
   #   end
   #   X = M::N
   #
-  #   M::N.parent # => M
-  #   X.parent    # => M
+  #   M::N.module_parent # => M
+  #   X.module_parent    # => M
   #
   # The parent of top-level and anonymous modules is Object.
   #
-  #   M.parent          # => Object
-  #   Module.new.parent # => Object
+  #   M.module_parent          # => Object
+  #   Module.new.module_parent # => Object
+  def module_parent
+    module_parent_name ? ActiveSupport::Inflector.constantize(module_parent_name) : Object
+  end
+
   def parent
-    parent_name ? ActiveSupport::Inflector.constantize(parent_name) : Object
+    ActiveSupport::Deprecation.warn(<<-MSG.squish)
+      `Module#parent` has been renamed to `module_parent`.
+      `parent` is deprecated and will be removed in Rails 6.1.
+    MSG
+    module_parent
   end
 
   # Returns all the parents of this module according to its name, ordered from
@@ -44,13 +60,13 @@ class Module
   #   end
   #   X = M::N
   #
-  #   M.parents    # => [Object]
-  #   M::N.parents # => [M, Object]
-  #   X.parents    # => [M, Object]
-  def parents
+  #   M.module_parents    # => [Object]
+  #   M::N.module_parents # => [M, Object]
+  #   X.module_parents    # => [M, Object]
+  def module_parents
     parents = []
-    if parent_name
-      parts = parent_name.split("::")
+    if module_parent_name
+      parts = module_parent_name.split("::")
       until parts.empty?
         parents << ActiveSupport::Inflector.constantize(parts * "::")
         parts.pop
@@ -59,4 +75,12 @@ class Module
     parents << Object unless parents.include? Object
     parents
   end
+
+  def parents
+    ActiveSupport::Deprecation.warn(<<-MSG.squish)
+      `Module#parents` has been renamed to `module_parents`.
+      `parents` is deprecated and will be removed in Rails 6.1.
+    MSG
+    module_parents
+  end
 end
-- 
cgit v1.2.3


From c401c43850e79a4d994e22dd8d82a69612bb947f Mon Sep 17 00:00:00 2001
From: Gannon McGibbon <gannon.mcgibbon@gmail.com>
Date: Tue, 2 Oct 2018 14:39:44 -0400
Subject: Fix call sites

---
 activesupport/lib/active_support/dependencies.rb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'activesupport/lib')

diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index 063d8d1587..66e0bea00e 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -521,8 +521,8 @@ module ActiveSupport #:nodoc:
         end
       elsif mod = autoload_module!(from_mod, const_name, qualified_name, path_suffix)
         return mod
-      elsif (parent = from_mod.parent) && parent != from_mod &&
-            ! from_mod.parents.any? { |p| p.const_defined?(const_name, false) }
+      elsif (parent = from_mod.module_parent) && parent != from_mod &&
+            ! from_mod.module_parents.any? { |p| p.const_defined?(const_name, false) }
         # If our parents do not have a constant named +const_name+ then we are free
         # to attempt to load upwards. If they do have such a constant, then this
         # const_missing must be due to from_mod::const_name, which should not
-- 
cgit v1.2.3