Module: Sidekiq::Queues

Defined in:
lib/sidekiq/testing.rb

Class Method Summary collapse

Class Method Details

.[](queue) ⇒ Object



167
168
169
# File 'lib/sidekiq/testing.rb', line 167

def [](queue)
  jobs_by_queue[queue]
end

.clear_allObject



194
195
196
197
# File 'lib/sidekiq/testing.rb', line 194

def clear_all
  jobs_by_queue.clear
  jobs_by_worker.clear
end

.clear_for(queue, klass) ⇒ Object



189
190
191
192
# File 'lib/sidekiq/testing.rb', line 189

def clear_for(queue, klass)
  jobs_by_queue[queue].clear
  jobs_by_worker[klass].clear
end

.delete_for(jid, queue, klass) ⇒ Object



184
185
186
187
# File 'lib/sidekiq/testing.rb', line 184

def delete_for(jid, queue, klass)
  jobs_by_queue[queue.to_s].delete_if { |job| job["jid"] == jid }
  jobs_by_worker[klass].delete_if { |job| job["jid"] == jid }
end

.jobs_by_queueObject



176
177
178
# File 'lib/sidekiq/testing.rb', line 176

def jobs_by_queue
  @jobs_by_queue ||= Hash.new { |hash, key| hash[key] = [] }
end

.jobs_by_workerObject



180
181
182
# File 'lib/sidekiq/testing.rb', line 180

def jobs_by_worker
  @jobs_by_worker ||= Hash.new { |hash, key| hash[key] = [] }
end

.push(queue, klass, job) ⇒ Object



171
172
173
174
# File 'lib/sidekiq/testing.rb', line 171

def push(queue, klass, job)
  jobs_by_queue[queue] << job
  jobs_by_worker[klass] << job
end