Method: Resque#dequeue

Defined in:
lib/resque.rb

#dequeue(klass, *args) ⇒ Object

This method can be used to conveniently remove a job from a queue. It assumes the class you’re passing it is a real Ruby class (not a string or reference) which either:

a) has a @queue ivar set
b) responds to `queue`

If either of those conditions are met, it will use the value obtained from performing one of the above operations to determine the queue.

If no queue can be inferred this method will raise a Resque::NoQueueError

If no args are given, this method will dequeue all jobs matching the provided class. See Resque::Job.destroy for more information.

Returns the number of jobs destroyed.

Example:

# Removes all jobs of class `UpdateNetworkGraph`
Resque.dequeue(GitHub::Jobs::UpdateNetworkGraph)

# Removes all jobs of class `UpdateNetworkGraph` with matching args.
Resque.dequeue(GitHub::Jobs::UpdateNetworkGraph, 'repo:135325')

This method is considered part of the stable API.



227
228
229
# File 'lib/resque.rb', line 227

def dequeue(klass, *args)
  Job.destroy(queue_from_class(klass), klass, *args)
end