aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib/active_job/queue_adapters/que_adapter.rb
blob: 51891ab07b3740aeeeb9410a8325f5c50c03a993 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'que'

module ActiveJob
  module QueueAdapters
    class QueAdapter
      class << self
        def enqueue(job)
          JobWrapper.enqueue job.serialize, queue: job.queue_name
        end

        def enqueue_at(job, timestamp)
          JobWrapper.enqueue job.serialize, queue: job.queue_name, run_at: Time.at(timestamp)
        end
      end

      class JobWrapper < Que::Job
        def run(job_data)
          Base.execute job_data
        end
      end
    end
  end
end