Class: ChainedJob::Process

Inherits:
Object
  • Object
show all
Defined in:
lib/chained_job/process.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_instance, worker_id, job_tag) ⇒ Process

Returns a new instance of Process.



13
14
15
16
17
# File 'lib/chained_job/process.rb', line 13

def initialize(job_instance, worker_id, job_tag)
  @job_instance = job_instance
  @worker_id = worker_id
  @job_tag = job_tag
end

Instance Attribute Details

#job_instanceObject (readonly)

Returns the value of attribute job_instance.



11
12
13
# File 'lib/chained_job/process.rb', line 11

def job_instance
  @job_instance
end

#job_tagObject (readonly)

Returns the value of attribute job_tag.



11
12
13
# File 'lib/chained_job/process.rb', line 11

def job_tag
  @job_tag
end

#worker_idObject (readonly)

Returns the value of attribute worker_id.



11
12
13
# File 'lib/chained_job/process.rb', line 11

def worker_id
  @worker_id
end

Class Method Details

.run(job_instance, worker_id, job_tag) ⇒ Object



7
8
9
# File 'lib/chained_job/process.rb', line 7

def self.run(job_instance, worker_id, job_tag)
  new(job_instance, worker_id, job_tag).run
end

Instance Method Details

#runObject



19
20
21
22
23
24
25
26
# File 'lib/chained_job/process.rb', line 19

def run
  with_hooks do
    return finished_worker unless argument

    job_instance.process(argument)
    job_instance.class.perform_later(worker_id, job_tag)
  end
end