Class: WarmingDrawer::Workers::BaseWorker

Inherits:
Object
  • Object
show all
Defined in:
lib/warming_drawer/workers/base_worker.rb

Direct Known Subclasses

UrlWorker

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.options(options_hash) ⇒ Object



16
17
18
19
# File 'lib/warming_drawer/workers/base_worker.rb', line 16

def options(options_hash)
  # TODO: change this based on queuing system
  sidekiq_options options_hash
end

.perform_with(*args) ⇒ Object

Sets up perform with or without queue



8
9
10
11
12
13
14
# File 'lib/warming_drawer/workers/base_worker.rb', line 8

def perform_with(*args)
  if WarmingDrawer.use_queue?
    perform_with_queue(args)
  else
    perform_without_queue(args)
  end
end

.perform_with_queue(*args) ⇒ Object



21
22
23
24
# File 'lib/warming_drawer/workers/base_worker.rb', line 21

def perform_with_queue(*args)
  # TODO: change this based on queuing system
  perform_async(args)
end

.perform_without_queue(*args) ⇒ Object



26
27
28
# File 'lib/warming_drawer/workers/base_worker.rb', line 26

def perform_without_queue(*args)
  new.perform(args)
end

Instance Method Details

#perform(*args) ⇒ Object

Does the actual work



33
34
35
# File 'lib/warming_drawer/workers/base_worker.rb', line 33

def perform(*args)
  raise 'Override perform in your worker'
end