While Rails up to 5 will use the classic autoloader and Rails 7+ will use zeitwerk, Rails 6.x can still be configured to use the classic autoloader: in that case, the code with throw an exception as it expects the latter behavior.
By adding a call to zeitwerk_enabled?, we support both cases, while having no impact on other Rails versions.
While Rails up to 5 will use the classic autoloader and Rails 7+ will use zeitwerk, Rails 6.x can still be configured to use the classic autoloader: in that case, the code with throw an exception as it expects the latter behavior.
By adding a call to
zeitwerk_enabled?
, we support both cases, while having no impact on other Rails versions.See Rails 7's and Rails 6's docs for more information.