-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Support for Rails 7.0 & Rails 7.1 #13
Conversation
Hi @marshall-lee, Hope you're well. Could you kindly review this PR when you have a moment? Thanks. |
Hi @mkhairi please fix the CI. |
@mkhairi Lets drop Ruby 2.5 support, it's way too old. |
lib/nested_record/lookup_const.rb
Outdated
def self.constantize(type_name) | ||
# TODO: Remove this when we drop support for Rails < 7.0 | ||
if ActiveSupport::Dependencies.respond_to?(:constantize) | ||
ActiveSupport::Dependencies.constantize(type_name) | ||
else | ||
type_name.constantize | ||
end | ||
end | ||
|
||
def self.safe_constantize(type_name) | ||
# TODO: Remove this when we drop support for Rails < 7.0 | ||
if ActiveSupport::Dependencies.respond_to?(:safe_constantize) | ||
ActiveSupport::Dependencies.safe_constantize(type_name) | ||
else | ||
type_name.safe_constantize | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def self.constantize(type_name) | |
# TODO: Remove this when we drop support for Rails < 7.0 | |
if ActiveSupport::Dependencies.respond_to?(:constantize) | |
ActiveSupport::Dependencies.constantize(type_name) | |
else | |
type_name.constantize | |
end | |
end | |
def self.safe_constantize(type_name) | |
# TODO: Remove this when we drop support for Rails < 7.0 | |
if ActiveSupport::Dependencies.respond_to?(:safe_constantize) | |
ActiveSupport::Dependencies.safe_constantize(type_name) | |
else | |
type_name.safe_constantize | |
end | |
end | |
# TODO: Remove this when we drop support for Rails < 7.0 | |
if ActiveSupport::VERSION::MAJOR < 7 | |
def self.constantize(type_name) | |
ActiveSupport::Dependencies.constantize(type_name) | |
end | |
def self.safe_constantize(type_name) | |
ActiveSupport::Dependencies.safe_constantize(type_name) | |
end | |
else | |
def self.constantize(type_name) | |
type_name.constantize | |
end | |
def self.safe_constantize(type_name) | |
type_name.safe_constantize | |
end | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marshall-lee, Opps.. Seems like it works without any rails version condition here. 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkhairi Yes it works but ActiveSupport::Dependencies.constantize
on older Rails leverages the ActiveSupport::Dependencies::ClassCache
. We should do it too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkhairi Yes it works but
ActiveSupport::Dependencies.constantize
on older Rails leverages theActiveSupport::Dependencies::ClassCache
. We should do it too.
@marshall-lee, Apologies, I'm unaware of about this. I have reinstated the Rails version condition based on the previous suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkhairi Sure, please squash the commits
- Fixed constantize method to make compatible with rails 7 - Drop support for ruby 2.5
No description provided.