Sha256: 7f352448870e9f00c8ba9f82ee136189e9e257c1dd6e0c7c8156a9d87a5bd9ee
Contents?: true
Size: 1.46 KB
Versions: 30
Compression:
Stored size: 1.46 KB
Contents
# frozen_string_literal: true module GoodJob module ActiveJobExtensions # Allows configuring whether GoodJob should emit a NOTIFY event when a job is enqueued. # Configuration will apply either globally to the Job Class, or individually to jobs # on initial enqueue and subsequent retries. # # @example # # Include the concern to your job class: # class MyJob < ApplicationJob # include GoodJob::ActiveJobExtensions::Notify # self.good_job_notify = false # end # # # Or, configure jobs individually to not notify: # MyJob.set(good_job_notify: false).perform_later # module NotifyOptions extend ActiveSupport::Concern module Prepends def enqueue(options = {}) self.good_job_notify = options[:good_job_notify] if options.key?(:good_job_notify) super end def serialize super.tap do |job_data| # Only serialize the value if present to reduce the size of the serialized job job_data["good_job_notify"] = good_job_notify unless good_job_notify.nil? end end def deserialize(job_data) super self.good_job_notify = job_data["good_job_notify"] end end included do prepend Prepends class_attribute :good_job_notify, instance_accessor: false, instance_predicate: false, default: nil attr_accessor :good_job_notify end end end end
Version data entries
30 entries across 30 versions & 1 rubygems