class SidekiqAdhocJob::Web::JobPresenter

Attributes

has_rest_args[R]
name[R]
optional_args[R]
optional_kw_args[R]
path_name[R]
queue[R]
required_args[R]
required_kw_args[R]

Public Class Methods

build_collection() click to toggle source

Builds the presenter instances for the schedule hash

@param @return [Array<JobPresenter>] an array with the instances of presenters

# File lib/sidekiq_adhoc_job/web/job_presenter.rb, line 27
def self.build_collection
  WorkerClassesLoader.worker_klasses.map do |path_name, worker_klass|
    convert_klass_name_to_presenter(path_name, worker_klass)
  end
end
convert_klass_name_to_presenter(path_name, klass_name) click to toggle source
# File lib/sidekiq_adhoc_job/web/job_presenter.rb, line 41
def self.convert_klass_name_to_presenter(path_name, klass_name)
  queue = SidekiqAdhocJob.config.strategy.get_queue_name(klass_name)
  class_inspector = SidekiqAdhocJob::Utils::ClassInspector.new(klass_name)
  args = class_inspector.parameters(:perform)
  new(klass_name, path_name, queue, args)
end
find(path_name) click to toggle source
# File lib/sidekiq_adhoc_job/web/job_presenter.rb, line 33
def self.find(path_name)
  klass_name = WorkerClassesLoader.find_worker_klass(path_name)

  return unless klass_name

  convert_klass_name_to_presenter(path_name, klass_name)
end
new(name, path_name, queue, args) click to toggle source

args: { req: [], opt: [] }

# File lib/sidekiq_adhoc_job/web/job_presenter.rb, line 12
def initialize(name, path_name, queue, args)
  @name = name
  @path_name = path_name
  @queue = queue
  @required_args = args[:req] || []
  @optional_args = args[:opt] || []
  @required_kw_args = args[:keyreq] || []
  @optional_kw_args = args[:key] || []
  @has_rest_args = !!args[:rest]
end

Public Instance Methods

no_arguments?() click to toggle source
# File lib/sidekiq_adhoc_job/web/job_presenter.rb, line 48
def no_arguments?
  required_args.empty? && optional_args.empty? && required_kw_args.empty? && optional_kw_args.empty? && !has_rest_args
end