Skip to content

Commit

Permalink
Keep the constantize behavior consistent for versions prior to Rails 7
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
carlosantoniodasilva committed Oct 8, 2021
1 parent bb879f7 commit 8593801
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,17 @@ def initialize(name)
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
Expand Down

1 comment on commit 8593801

@gobijan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx for merging into master

Please sign in to comment.