Method: Chore::Job::ClassMethods#queue_options

Defined in:
lib/chore/job.rb

#queue_options(opts = {}) ⇒ Object

Pass a hash of options to queue_options the included class’s use of Chore::Job opts has just the one required option.

  • :name: which should map to the name of the queue this job should be published to.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/chore/job.rb', line 49

def queue_options(opts = {})
  @chore_options = (@chore_options || DEFAULT_OPTIONS).merge(opts_from_cli).merge(opts)

  required_options.each do |k|
    raise ArgumentError.new("#{self.to_s} :#{k} is a required option for Chore::Job") unless @chore_options[k]
  end

  if @chore_options.key?(:backoff)
    if !@chore_options[:backoff].is_a?(Proc)
      raise ArgumentError, "#{self.to_s}: backoff must be a lambda or Proc"
    elsif @chore_options[:backoff].arity != 1
      raise ArgumentError, "#{self.to_s}: backoff must accept a single argument"
    end
  end

  if @chore_options.key?(:dedupe_lambda)
    if !@chore_options[:dedupe_lambda].is_a?(Proc)
      raise ArgumentError, "#{self.to_s}: dedupe_lambda must be a lambda or Proc"
    end
  end
end