From 7b980773a8d16bccfde9649e7a7ea069cae36c02 Mon Sep 17 00:00:00 2001 From: "Ben Sheldon [he/him]" Date: Wed, 10 Jul 2024 07:26:15 -0700 Subject: [PATCH] Add Active Support load hooks for Job and (Discrete)Execution; move all outside class definition bodies (#1414) --- app/controllers/good_job/application_controller.rb | 4 ++-- app/models/good_job/base_record.rb | 4 ++-- app/models/good_job/discrete_execution.rb | 2 ++ app/models/good_job/job.rb | 2 ++ lib/good_job.rb | 4 ++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/good_job/application_controller.rb b/app/controllers/good_job/application_controller.rb index 65feec652..ea58ef4cb 100644 --- a/app/controllers/good_job/application_controller.rb +++ b/app/controllers/good_job/application_controller.rb @@ -57,7 +57,7 @@ def current_locale I18n.default_locale end end - - ActiveSupport.run_load_hooks(:good_job_application_controller, self) end end + +ActiveSupport.run_load_hooks(:good_job_application_controller, GoodJob::ApplicationController) diff --git a/app/models/good_job/base_record.rb b/app/models/good_job/base_record.rb index f6f0d809e..a293464ad 100644 --- a/app/models/good_job/base_record.rb +++ b/app/models/good_job/base_record.rb @@ -43,7 +43,7 @@ def self.with_logger_silenced(silent: true, &block) def self.bind_value(name, value, type_class) Arel::Nodes::BindParam.new(ActiveRecord::Relation::QueryAttribute.new(name, value, type_class.new)) end - - ActiveSupport.run_load_hooks(:good_job_base_record, self) end end + +ActiveSupport.run_load_hooks(:good_job_base_record, GoodJob::BaseRecord) diff --git a/app/models/good_job/discrete_execution.rb b/app/models/good_job/discrete_execution.rb index e645ae571..bde19a05d 100644 --- a/app/models/good_job/discrete_execution.rb +++ b/app/models/good_job/discrete_execution.rb @@ -60,3 +60,5 @@ def filtered_error_backtrace end end end + +ActiveSupport.run_load_hooks(:good_job_execution, GoodJob::DiscreteExecution) diff --git a/app/models/good_job/job.rb b/app/models/good_job/job.rb index 05282c773..272ecad78 100644 --- a/app/models/good_job/job.rb +++ b/app/models/good_job/job.rb @@ -224,3 +224,5 @@ def _discard_job(message) end end end + +ActiveSupport.run_load_hooks(:good_job_job, GoodJob::Job) diff --git a/lib/good_job.rb b/lib/good_job.rb index c80461202..01cc76780 100644 --- a/lib/good_job.rb +++ b/lib/good_job.rb @@ -291,6 +291,6 @@ def self.deprecator def self.migrated? true end - - ActiveSupport.run_load_hooks(:good_job, self) end + +ActiveSupport.run_load_hooks(:good_job, GoodJob)