This replaces AutoRegistration with a Loader that uses Zeitwerk. I'll open a separate PR once this is merged with the actual API improvements, what this PR does essentially, is providing a better and simpler implementation for loading components. Things like options and behavior still need to be improved.
TODO
[x] Figure out how to "reset" Zeitwerk in specs because it keeps a global Registry which breaks specs when you run them all
[x] Refactor AutoRegistration into a component loader ~where each instance handles a specific component type~ turned out a single loader is needed because zeitwerk can't handle multiple dirs that have the same parent
[x] Refactor Setup#auto_registration into Setup#auto_register and refine its behavior to use the new loader
[x] Figure out if Zeitwerk can support passing a namespace that is not part of a file path. ie lib/relations/users.rb where the constant is actually MyNamespace::Users - it cannot and this is fine, because this is a weird use case that's completely non-standard so I'll move this behavior to a backward-compatibility "layer" silly me missed the fact that Zeitwerk actually supports passing "namespace" option to push_dir, so this use case is supported after all
[x] add rom/compat for backward-compatibility APIs. ~Something like ROM.include(ROM::Compat[5.0]) should suffice~ sticking to plain require "rom/compat" for now
[x] improve on_load handling because it actually yields path too, so we can infer component type from this easily
This replaces AutoRegistration with a Loader that uses Zeitwerk. I'll open a separate PR once this is merged with the actual API improvements, what this PR does essentially, is providing a better and simpler implementation for loading components. Things like options and behavior still need to be improved.
TODO
AutoRegistration
into a component loader ~where each instance handles a specific component type~ turned out a single loader is needed because zeitwerk can't handle multiple dirs that have the same parentSetup#auto_registration
intoSetup#auto_register
and refine its behavior to use the new loaderlib/relations/users.rb
where the constant is actuallyMyNamespace::Users
-it cannot and this is fine, because this is a weird use case that's completely non-standard so I'll move this behavior to a backward-compatibility "layer"silly me missed the fact that Zeitwerk actually supports passing "namespace" option to push_dir, so this use case is supported after allrom/compat
for backward-compatibility APIs. ~Something likeROM.include(ROM::Compat[5.0])
should suffice~ sticking to plainrequire "rom/compat"
for nowon_load
handling because it actually yields path too, so we can infer component type from this easily