Skip to content

Commit 3e3504b

Browse files
committed
Delete AS::Dependencies.constantize
1 parent 074c7f5 commit 3e3504b

File tree

5 files changed

+5
-27
lines changed

5 files changed

+5
-27
lines changed

actionpack/lib/action_dispatch/http/request.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def controller_class_for(name)
8787
controller_param = name.underscore
8888
const_name = controller_param.camelize << "Controller"
8989
begin
90-
ActiveSupport::Dependencies.constantize(const_name)
90+
const_name.constantize
9191
rescue NameError => error
9292
if error.missing_name == const_name || const_name.start_with?("#{error.missing_name}::")
9393
raise MissingController.new(error.message, error.name)

activerecord/lib/active_record/inheritance.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# frozen_string_literal: true
22

3+
require "active_support/inflector"
34
require "active_support/core_ext/hash/indifferent_access"
45

56
module ActiveRecord
@@ -181,7 +182,7 @@ def sti_name
181182
# It is used to find the class correspondent to the value stored in the inheritance column.
182183
def sti_class_for(type_name)
183184
if store_full_sti_class && store_full_class_name
184-
ActiveSupport::Dependencies.constantize(type_name)
185+
type_name.constantize
185186
else
186187
compute_type(type_name)
187188
end
@@ -203,7 +204,7 @@ def polymorphic_name
203204
# It is used to find the class correspondent to the value stored in the polymorphic type column.
204205
def polymorphic_class_for(name)
205206
if store_full_class_name
206-
ActiveSupport::Dependencies.constantize(name)
207+
name.constantize
207208
else
208209
compute_type(name)
209210
end
@@ -235,7 +236,7 @@ def compute_type(type_name)
235236
if type_name.start_with?("::")
236237
# If the type is prefixed with a scope operator then we assume that
237238
# the type_name is an absolute reference.
238-
ActiveSupport::Dependencies.constantize(type_name)
239+
type_name.constantize
239240
else
240241
type_candidate = @_type_candidates_cache[type_name]
241242
if type_candidate && type_constant = ActiveSupport::Dependencies.safe_constantize(type_candidate)

activesupport/lib/active_support/dependencies.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,6 @@ def search_for_file(path_suffix)
8282
nil # Gee, I sure wish we had first_match ;-)
8383
end
8484

85-
# Get the reference for class named +name+.
86-
# Raises an exception if referenced class does not exist.
87-
def constantize(name)
88-
Inflector.constantize(name)
89-
end
90-
9185
# Get the reference for class named +name+ if one exists.
9286
# Otherwise returns +nil+.
9387
def safe_constantize(name)

activesupport/lib/active_support/dependencies/zeitwerk_integration.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ def clear
1616
end
1717
end
1818

19-
def constantize(cpath)
20-
ActiveSupport::Inflector.constantize(cpath)
21-
end
22-
2319
def safe_constantize(cpath)
2420
ActiveSupport::Inflector.safe_constantize(cpath)
2521
end

railties/test/application/zeitwerk_integration_test.rb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,6 @@ class RESTfulController < ApplicationController
6161
assert RESTfulController
6262
end
6363

64-
test "constantize returns the value stored in the constant" do
65-
app_file "app/models/admin/user.rb", "class Admin::User; end"
66-
boot
67-
68-
assert_same Admin::User, deps.constantize("Admin::User")
69-
end
70-
71-
test "constantize raises if the constant is unknown" do
72-
boot
73-
74-
assert_raises(NameError) { deps.constantize("Admin") }
75-
end
76-
7764
test "safe_constantize returns the value stored in the constant" do
7865
app_file "app/models/admin/user.rb", "class Admin::User; end"
7966
boot

0 commit comments

Comments
 (0)