Remove deprecated `Module#reachable?` method

上级 0ce67d3c
* Remove deprecated `Module#reachable?` method.
*Rafael Mendonça França*
* Remove deprecated `#acronym_regex` method from `Inflections`.
*Rafael Mendonça França*
......
......@@ -3,7 +3,6 @@
require "active_support/core_ext/module/aliasing"
require "active_support/core_ext/module/introspection"
require "active_support/core_ext/module/anonymous"
require "active_support/core_ext/module/reachable"
require "active_support/core_ext/module/attribute_accessors"
require "active_support/core_ext/module/attribute_accessors_per_thread"
require "active_support/core_ext/module/attr_internal"
......
......@@ -3,9 +3,4 @@
require "active_support/core_ext/module/anonymous"
require "active_support/core_ext/string/inflections"
class Module
def reachable? #:nodoc:
!anonymous? && name.safe_constantize.equal?(self)
end
deprecate :reachable?
end
ActiveSupport::Deprecation.warn("reachable is deprecated and will be removed from the framework.")
# frozen_string_literal: true
require "abstract_unit"
require "active_support/core_ext/module/reachable"
class AnonymousTest < ActiveSupport::TestCase
test "an anonymous class or module is not reachable" do
assert_deprecated do
assert_not_predicate Module.new, :reachable?
assert_not_predicate Class.new, :reachable?
end
end
test "ordinary named classes or modules are reachable" do
assert_deprecated do
assert_predicate Kernel, :reachable?
assert_predicate Object, :reachable?
end
end
test "a named class or module whose constant has gone is not reachable" do
c = eval "class C; end; C"
m = eval "module M; end; M"
self.class.send(:remove_const, :C)
self.class.send(:remove_const, :M)
assert_deprecated do
assert_not_predicate c, :reachable?
assert_not_predicate m, :reachable?
end
end
test "a named class or module whose constants store different objects are not reachable" do
c = eval "class C; end; C"
m = eval "module M; end; M"
self.class.send(:remove_const, :C)
self.class.send(:remove_const, :M)
eval "class C; end"
eval "module M; end"
assert_deprecated do
assert_predicate C, :reachable?
assert_predicate M, :reachable?
assert_not_predicate c, :reachable?
assert_not_predicate m, :reachable?
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册