FIX: Fix `Jobs::Onceoff.enqueue_all` undefined method for nilClass error (#28073)

In development, classes are lazy loaded so `Jobs::Onceoff.onceoff_job_klasses`
may not have been set. This is not a problem in production cause stuff
is eager loaded.

Follow-up to f4d06f195d
This commit is contained in:
Alan Guo Xiang Tan 2024-07-25 15:52:42 +08:00 committed by GitHub
parent 5b05cdfbd9
commit 5a37fa3760
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 3 deletions

View File

@ -4,11 +4,14 @@ class Jobs::Onceoff < ::Jobs::Base
sidekiq_options retry: false
class << self
attr_reader :onceoff_job_klasses
@@onceoff_job_klasses = Set.new
def inherited(klass)
@onceoff_job_klasses ||= Set.new
@onceoff_job_klasses << klass
@@onceoff_job_klasses << klass
end
def onceoff_job_klasses
@@onceoff_job_klasses
end
end