Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Please, include a summary of what the PR is for:
What is the problem it is solving?
Implements autoloading on Active Resources classes so they don't load early unnecessarily. This improves load times for Rails applications, especially in instances where they are not used.
What is the context of these changes?
I don't want this gem to load Active Resource early, it causes unnecessary speed regressions in my application's boot time.
What is the impact of this PR?
Shaves about 40ms off require time. The remainder is caused by other gems we're requiring like GraphQL, but it implements autoloading in the latest version. The time savings would be much greater in apps due to the amount of load hooks for Active Resource in place.
How has this been tested?
Test this with:
Note, you might have to add racc to the gemfile and require ostruct before the gem require if you're running on Ruby 3.3+.
Please, describe the tests that you ran to verify your changes.
I verified eager loading does in fact load the autoloaded constants. I didn't add anything to the test suite because this is a very old gem version that's on its way out, so we probably don't need continued assurance that autoloading works.
Checklist:
cc @sle-c