Class: Delayed::JobWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/delayed/job_wrapper.rb

Overview

rubocop:disable Betterment/ActiveJobPerformable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_or_data) ⇒ JobWrapper

Returns a new instance of JobWrapper.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/delayed/job_wrapper.rb', line 7

def initialize(job_or_data)
  # During enqueue the job instance is passed in directly, saves us deserializing
  # it to find out how to queue the job.
  # During load from the db, we get a data hash passed in so deserialize lazily.
  if job_or_data.is_a?(ActiveJob::Base)
    @job = job_or_data
    @job_data = job_or_data.serialize
  else
    @job_data = job_or_data
  end
end

Instance Attribute Details

#job_dataObject

Returns the value of attribute job_data.



3
4
5
# File 'lib/delayed/job_wrapper.rb', line 3

def job_data
  @job_data
end

Instance Method Details

#display_nameObject



19
20
21
# File 'lib/delayed/job_wrapper.rb', line 19

def display_name
  job_data['job_class']
end

#encode_with(coder) ⇒ Object



29
30
31
# File 'lib/delayed/job_wrapper.rb', line 29

def encode_with(coder)
  coder['job_data'] = @job_data
end

#performObject



23
24
25
26
27
# File 'lib/delayed/job_wrapper.rb', line 23

def perform
  ActiveJob::Callbacks.run_callbacks(:execute) do
    job.perform_now
  end
end