Class: ActiveJob::QueueAdapters::TestAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/active_job/queue_adapters/test_adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#enqueued_jobsObject

Provides a store of all the enqueued jobs with the TestAdapter so you can check them.



9
10
11
# File 'lib/active_job/queue_adapters/test_adapter.rb', line 9

def enqueued_jobs
  @enqueued_jobs ||= []
end

#perform_enqueued_at_jobsObject

Returns the value of attribute perform_enqueued_at_jobs.



5
6
7
# File 'lib/active_job/queue_adapters/test_adapter.rb', line 5

def perform_enqueued_at_jobs
  @perform_enqueued_at_jobs
end

#perform_enqueued_jobsObject

Returns the value of attribute perform_enqueued_jobs.



5
6
7
# File 'lib/active_job/queue_adapters/test_adapter.rb', line 5

def perform_enqueued_jobs
  @perform_enqueued_jobs
end

#performed_jobsObject

Provides a store of all the performed jobs with the TestAdapter so you can check them.



14
15
16
# File 'lib/active_job/queue_adapters/test_adapter.rb', line 14

def performed_jobs
  @performed_jobs ||= []
end

Instance Method Details

#enqueue(job) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/active_job/queue_adapters/test_adapter.rb', line 18

def enqueue(job)
  if perform_enqueued_jobs
    performed_jobs << {job: job.class, args: job.arguments, queue: job.queue_name}
    job.perform_now
  else
    enqueued_jobs << {job: job.class, args: job.arguments, queue: job.queue_name}
  end
end

#enqueue_at(job, timestamp) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/active_job/queue_adapters/test_adapter.rb', line 27

def enqueue_at(job, timestamp)
  if perform_enqueued_at_jobs
    performed_jobs << {job: job.class, args: job.arguments, queue: job.queue_name, at: timestamp}
    job.perform_now
  else
    enqueued_jobs << {job: job.class, args: job.arguments, queue: job.queue_name, at: timestamp}
  end
end