Class: Workhorse::Jobs::RunActiveJob

Inherits:
Object
  • Object
show all
Defined in:
lib/workhorse/jobs/run_active_job.rb

Overview

Wrapper job for executing ActiveJob instances within Workhorse. This job handles the deserialization and execution of ActiveJob jobs that have been enqueued through the Workhorse adapter.

Examples:

Internal usage

wrapper = RunActiveJob.new(job.serialize)
wrapper.perform

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_data) ⇒ RunActiveJob

Creates a new ActiveJob wrapper.

Parameters:

  • job_data (Hash)

    Serialized ActiveJob data from job.serialize



16
17
18
# File 'lib/workhorse/jobs/run_active_job.rb', line 16

def initialize(job_data)
  @job_data = job_data
end

Instance Attribute Details

#job_dataHash (readonly)

Returns Serialized ActiveJob data.

Returns:

  • (Hash)

    Serialized ActiveJob data



11
12
13
# File 'lib/workhorse/jobs/run_active_job.rb', line 11

def job_data
  @job_data
end

Instance Method Details

#job_classClass?

Returns the ActiveJob class for this job.

Returns:

  • (Class, nil)

    The job class or nil if not found



23
24
25
# File 'lib/workhorse/jobs/run_active_job.rb', line 23

def job_class
  @job_data['job_class'].safe_constantize
end

#performvoid

This method returns an undefined value.

Executes the wrapped ActiveJob.



30
31
32
# File 'lib/workhorse/jobs/run_active_job.rb', line 30

def perform
  ActiveJob::Base.execute(@job_data)
end