module RabbitJobs::Job::ClassMethods

DSL method for jobs

Attributes

on_error_hooks[R]

Public Instance Methods

expires_in(seconds = nil) click to toggle source
# File lib/rabbit_jobs/job.rb, line 107
def expires_in(seconds = nil)
  @expires_in = seconds.to_i if seconds
  @expires_in
end
on_error(*hooks) click to toggle source
# File lib/rabbit_jobs/job.rb, line 114
def on_error(*hooks)
  @on_error_hooks ||= []
  hooks.each do |proc_or_symbol|
    unless proc_or_symbol.is_a?(Proc) || proc_or_symbol.is_a?(Symbol)
      fail ArgumentError.new, 'Pass proc or symbol to on_error hook'
    end
    @on_error_hooks << proc_or_symbol
  end
end
perform(*params) click to toggle source
# File lib/rabbit_jobs/job.rb, line 133
def perform(*params)
  new.perform(*params)
end
perform_async(*args) click to toggle source
# File lib/rabbit_jobs/job.rb, line 129
def perform_async(*args)
  RJ::Publisher.publish_to(@rj_queue, self, *args)
end
queue(routing_key) click to toggle source
# File lib/rabbit_jobs/job.rb, line 124
def queue(routing_key)
  fail ArgumentError, 'routing_key is blank' if routing_key.blank?
  @rj_queue = routing_key.to_sym
end