Sha256: 21a264719967c4800e8d42b1971a5993fd987887d033ca2c6b2d9fb8d9510f04
Contents?: true
Size: 917 Bytes
Versions: 3
Compression:
Stored size: 917 Bytes
Contents
module SidekiqWebWorkers class JobRunner attr_reader :worker_name def self.execute!(*args) new(*args).execute! end def initialize(worker_name:, worker_parameters:, perform_in: nil) @worker_name = worker_name @worker_parameters = worker_parameters @perform_in = perform_in end def execute! enqueue_worker end private def enqueue_worker args = arguments_array if @perform_in.present? worker.perform_in(@perform_in.to_i.minutes, *args) else worker.perform_async(*args) end end private def arguments_array # {param_name: param_value,....} @worker_parameters .values # sidekiq perform_async only takes the values not named params .map{|i| i.present? ? i : nil} # convert empty strings into nil end private def worker worker_name.constantize end end end
Version data entries
3 entries across 3 versions & 1 rubygems