module Litejob::Concern

def client

def client
  @client ||= Client.new
end

def delete(id)

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

def litejob_options(options)

def litejob_options(options)
  @litejob_options = options
end

def perform_async(*params)

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

def perform_at(time, *params)

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

def perform_in(delay, *params)

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

def queue_as(queue_name)

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

def queue_name

def queue_name
  @queue_name || "default"
end