class TResque::DelayExecutionWorker

Public Class Methods

get_lock_namespace(options) click to toggle source

handle dynamic locks

# File lib/tresque/delay_execution_worker.rb, line 12
def get_lock_namespace(options)
  options["lock_namespace"] || options["class_name"]
end
get_queue_lock_attributes(options) click to toggle source
# File lib/tresque/delay_execution_worker.rb, line 16
def get_queue_lock_attributes(options)
  return nil unless options["queue_lock"]
  [options["queue_lock"]].flatten
end
get_worker_lock_attributes(options) click to toggle source
# File lib/tresque/delay_execution_worker.rb, line 21
def get_worker_lock_attributes(options)
  return nil unless options["worker_lock"]
  [options["worker_lock"]].flatten
end

Public Instance Methods

work() click to toggle source
# File lib/tresque/delay_execution_worker.rb, line 27
def work
  return unless record
  if args.nil? || args.empty?
    record.send(self.method_name)
  else
    record.send(self.method_name, *self.args)
  end
end

Protected Instance Methods

klass() click to toggle source
# File lib/tresque/delay_execution_worker.rb, line 38
def klass
  @klass ||= class_name.constantize
end
record() click to toggle source
# File lib/tresque/delay_execution_worker.rb, line 42
def record
  @record ||= if id.nil?
    klass
  else
    if klass.respond_to?(:find_by)
      klass.find_by(id: id)
    elsif klass.respond_to?(:find_by_id)
      klass.find_by_id(id)
    else
      klass.find(id)
    end
  end
end