diff --git a/Gemfile.lock b/Gemfile.lock index b27d8740..4a1f6270 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,6 +7,7 @@ PATH activerecord (>= 6.0) job-iteration (>= 1.3.6) railties (>= 6.0) + zeitwerk (>= 2.6.2) GEM remote: https://rubygems.org/ diff --git a/app/models/maintenance_tasks/task.rb b/app/models/maintenance_tasks/task.rb index 929418bc..e7825abd 100644 --- a/app/models/maintenance_tasks/task.rb +++ b/app/models/maintenance_tasks/task.rb @@ -187,13 +187,7 @@ def load_constants namespace = MaintenanceTasks.tasks_module.safe_constantize return unless namespace - load_const = lambda do |root| - root.constants.each do |name| - object = root.const_get(name) - load_const.call(object) if object.instance_of?(Module) - end - end - load_const.call(namespace) + Rails.autoloaders.main.eager_load_namespace(namespace) end end diff --git a/maintenance_tasks.gemspec b/maintenance_tasks.gemspec index 91349ffe..342a80ec 100644 --- a/maintenance_tasks.gemspec +++ b/maintenance_tasks.gemspec @@ -26,4 +26,5 @@ Gem::Specification.new do |spec| spec.add_dependency("activerecord", ">= 6.0") spec.add_dependency("job-iteration", ">= 1.3.6") spec.add_dependency("railties", ">= 6.0") + spec.add_dependency("zeitwerk", ">= 2.6.2") end