Sha256: 70bdbc284319941116d616f1f6633f2d8a4eab51baaf0170426b500b3abd2f5e

Contents?: true

Size: 391 Bytes

Versions: 1

Compression:

Stored size: 391 Bytes

Contents

# frozen_string_literal: true

require 'json'

module Quiq
  class Worker
    def initialize(job)
      # TODO: handle deserialization errors
      @job = JSON.parse(job) rescue nil
    end

    def run
      return if @job.nil?

      Async do
        klass = Object.const_get(@job['job_class'])
        args = @job['arguments']
        klass.new.perform(*args)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quiq-0.1.0 lib/quiq/worker.rb