Module: Delayed::UniqueJob
- Included in:
- Job
- Defined in:
- lib/delayed_job_unique/unique_job.rb
Instance Method Summary collapse
Instance Method Details
#enqueue_once(*args, **kwargs) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/delayed_job_unique/unique_job.rb', line 5 def enqueue_once(*args, **kwargs) job = args.first raise "Job `#{job.class}` must respond to `#unique_key`" unless job.respond_to?(:unique_key) props = kwargs.merge({key: job.unique_key}) Delayed::Job.transaction do if job_already_enqueued?(job) Delayed::Worker.logger.error "Job with key: #{job.unique_key} it's already on queue" false else Delayed::Job.enqueue(job, props) end end end |