Module: Resque

Defined in:
lib/resque_ext/job.rb,
lib/resque_ext/resque.rb,
lib/resque_solo/unique_job.rb

Defined Under Namespace

Modules: Plugins Classes: Job

Class Method Summary collapse

Class Method Details

.enqueue_to(queue, klass, *args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/resque_ext/resque.rb', line 7

def enqueue_to(queue, klass, *args)
  # Perform before_enqueue hooks. Don't perform enqueue if any hook returns false
  before_hooks = Plugin.before_enqueue_hooks(klass).collect do |hook|
    klass.send(hook, *args)
  end
  return nil if before_hooks.any? { |result| result == false }

  result = Job.create(queue, klass, *args)
  return nil if result == "EXISTED"

  Plugin.after_enqueue_hooks(klass).each do |hook|
    klass.send(hook, *args)
  end

  true
end

.enqueued?(klass, *args) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/resque_ext/resque.rb', line 24

def enqueued?(klass, *args)
  enqueued_in?(queue_from_class(klass), klass, *args)
end

.enqueued_in?(queue, klass, *args) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
31
32
# File 'lib/resque_ext/resque.rb', line 28

def enqueued_in?(queue, klass, *args)
  item = { class: klass.to_s, args: args }
  return nil unless ResqueSolo::Queue.is_unique?(item)
  ResqueSolo::Queue.queued?(queue, item)
end

.remove_queue_with_cleanup(queue) ⇒ Object Also known as: remove_queue



34
35
36
37
# File 'lib/resque_ext/resque.rb', line 34

def remove_queue_with_cleanup(queue)
  remove_queue_without_cleanup(queue)
  ResqueSolo::Queue.cleanup(queue)
end