Class: Rector::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/rector/worker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Worker

Returns a new instance of Worker.



5
6
7
8
9
10
11
# File 'lib/rector/worker.rb', line 5

def initialize(id)
  @id      = id
  @data    = Hash.new

  @backend = Rector.backend_for(job_id)
  @backend.add_worker(@id)
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



3
4
5
# File 'lib/rector/worker.rb', line 3

def data
  @data
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/rector/worker.rb', line 3

def id
  @id
end

Instance Method Details

#finishObject



17
18
19
20
# File 'lib/rector/worker.rb', line 17

def finish
  @backend.update_job_data_from_hash(@data)
  @backend.finish_worker(@id)
end

#job_idObject



13
14
15
# File 'lib/rector/worker.rb', line 13

def job_id
  @id.split(":").first
end