Skip to content

Commit 8593801

Browse files
Keep the constantize behavior consistent for versions prior to Rails 7
Use `AS::Dependencies` as before if we still can, otherwise use the new direct `constantize` call for Rails 7+. Leave a TODO to help remind us this can be removed once we drop support to Rails versions prior to 7 in the future.
1 parent bb879f7 commit 8593801

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lib/devise.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,17 @@ def initialize(name)
313313
end
314314

315315
def get
316-
@name.constantize
316+
# TODO: Remove AS::Dependencies usage when dropping support to Rails < 7.
317+
if ActiveSupport::Dependencies.respond_to?(:constantize)
318+
ActiveSupport::Dependencies.constantize(@name)
319+
else
320+
@name.constantize
321+
end
317322
end
318323
end
319324

320325
def self.ref(arg)
326+
# TODO: Remove AS::Dependencies usage when dropping support to Rails < 7.
321327
if ActiveSupport::Dependencies.respond_to?(:reference)
322328
ActiveSupport::Dependencies.reference(arg)
323329
end

0 commit comments

Comments
 (0)