class Workerholic::JobWrapper

Attributes

arguments[R]
execute_at[RW]
klass[R]
queue[R]
retry_count[RW]
statistics[R]
wrapper[R]

Public Class Methods

new(options={}) click to toggle source
# File lib/workerholic/job_wrapper.rb, line 6
def initialize(options={})
  @klass = options[:klass]
  @wrapper = options[:wrapper]
  @arguments = options[:arguments]
  @queue = options[:queue]
  @execute_at = options[:execute_at]
  @retry_count = options[:retry_count] || 0
  @statistics = JobStatistics.new(options[:statistics] || {})
end

Public Instance Methods

==(other) click to toggle source
# File lib/workerholic/job_wrapper.rb, line 39
def ==(other)
  to_hash == other.to_hash
end
perform() click to toggle source
# File lib/workerholic/job_wrapper.rb, line 28
def perform
  if wrapper && wrapper.name == 'ActiveJob::QueueAdapters::WorkerholicAdapter::JobWrapper'
    wrapper.new.perform(
      'job_class' => klass,
      'arguments' => arguments
    )
  else
    klass.new.perform(*arguments)
  end
end
to_hash() click to toggle source
# File lib/workerholic/job_wrapper.rb, line 16
def to_hash
  {
    klass: klass,
    wrapper: wrapper,
    arguments: arguments,
    queue: queue,
    retry_count: retry_count,
    execute_at: execute_at,
    statistics: statistics.to_hash
  }
end