Module: Litejob::Concern

Defined in:
lib/litejob/concern.rb

Overview

Litejob::Concern is responsible for providing an interface to job classes

Instance Method Summary collapse

Instance Method Details

#delete(id) ⇒ Object



25
26
27
# File 'lib/litejob/concern.rb', line 25

def delete(id)
  client.delete(id)
end

#litejob_options(options) ⇒ Object



33
34
35
# File 'lib/litejob/concern.rb', line 33

def litejob_options(options)
  @litejob_options = options
end

#perform_async(*params) ⇒ Object



8
9
10
11
# File 'lib/litejob/concern.rb', line 8

def perform_async(*params)
  @litejob_options ||= {}
  client.push(name, params, @litejob_options.merge(delay: 0, queue: queue_name))
end

#perform_at(time, *params) ⇒ Object



13
14
15
16
17
# File 'lib/litejob/concern.rb', line 13

def perform_at(time, *params)
  @litejob_options ||= {}
  delay = time.to_i - Time.now.to_i
  client.push(name, params, @litejob_options.merge(delay: delay, queue: queue_name))
end

#perform_in(delay, *params) ⇒ Object Also known as: perform_after



19
20
21
22
# File 'lib/litejob/concern.rb', line 19

def perform_in(delay, *params)
  @litejob_options ||= {}
  client.push(name, params, @litejob_options.merge(delay: delay, queue: queue_name))
end

#queue_as(queue_name) ⇒ Object



29
30
31
# File 'lib/litejob/concern.rb', line 29

def queue_as(queue_name)
  @queue_name = queue_name.to_s
end