Fix Zeitwerk conventions for Refinery::Pages::Finder
#3524
Merged
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.
Regarding #3523
The issue stems from the definition of
Refinery::Pages::Finderand its sibling classes (Refinery::Pages::FinderByTitleand so on). These are all defined beside each other inpages/lib/refinery/pages/finder.rbwhich gets required inpages/app/models/refinery/page.rb.When reloading, zeitwerk reloads the model, which in turn loads the finder again. But because the file is named
finder.rb, onlyRefinery::Pages::Findergets unloaded and reloaded again. All other classes stay loaded and would be patched by the reload. But becauseRefinery::Pages::Finderhas been reloaded and initialized again, it got a newobject_id, thus triggering thesuperclass mismatcherror.The solution, that fixed the error, was to move all sibling-classes of
Refinery::Pages::Finderinto it, making them children ofRefinery::Pages::Finder. Because they are only called insideRefinery::Pages::Finderitself, this should not make problems.I am not sure, if this is the best or most elegant solution, if it introduces side effects or if there are other parts of refinery, that suffer the same issues.