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.
This commit is contained in:
Carlos Antonio da Silva 2021-10-08 08:31:13 -03:00
parent bb879f7154
commit 8593801130
1 changed files with 7 additions and 1 deletions

View File

@ -313,11 +313,17 @@ module Devise
end
def get
@name.constantize
# TODO: Remove AS::Dependencies usage when dropping support to Rails < 7.
if ActiveSupport::Dependencies.respond_to?(:constantize)
ActiveSupport::Dependencies.constantize(@name)
else
@name.constantize
end
end
end
def self.ref(arg)
# TODO: Remove AS::Dependencies usage when dropping support to Rails < 7.
if ActiveSupport::Dependencies.respond_to?(:reference)
ActiveSupport::Dependencies.reference(arg)
end