Class: Workhorse::Performer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db_job_id, worker) ⇒ Performer

Returns a new instance of Performer.



5
6
7
8
9
# File 'lib/workhorse/performer.rb', line 5

def initialize(db_job_id, worker)
  @db_job = Workhorse::DbJob.find(db_job_id)
  @worker = worker
  @started = false
end

Instance Attribute Details

#workerObject (readonly)

Returns the value of attribute worker.



3
4
5
# File 'lib/workhorse/performer.rb', line 3

def worker
  @worker
end

Instance Method Details

#performObject



11
12
13
14
15
16
17
# File 'lib/workhorse/performer.rb', line 11

def perform
  fail 'Performer can only run once.' if @started
  @started = true
  perform!
rescue Exception => e
  Workhorse.on_exception.call(e)
end