Class: Aker::Job

Inherits:
ApplicationRecord show all
Defined in:
app/models/aker/job.rb

Overview

Individual element of work from a work order.

Instance Method Summary collapse

Methods inherited from ApplicationRecord

convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Warren::BroadcastMessages

#broadcast, included, #queue_associated_for_broadcast, #queue_for_broadcast, #warren

Instance Method Details

#as_json(_options = {}) ⇒ Object


17
18
19
20
21
22
23
24
# File 'app/models/aker/job.rb', line 17

def as_json(_options = {})
  {
    job: {
      id: id,
      aker_job_id: aker_job_id
    }
  }
end

#changed_containersObject


34
35
36
# File 'app/models/aker/job.rb', line 34

def changed_containers
  []
end

#container_message(_container) ⇒ Object


42
43
44
# File 'app/models/aker/job.rb', line 42

def container_message(_container)
  {}
end

#containers_messageObject


46
47
48
# File 'app/models/aker/job.rb', line 46

def containers_message
  changed_containers.map { |c| container_message(c) }
end

#finish_messageObject


58
59
60
61
62
63
64
65
66
67
# File 'app/models/aker/job.rb', line 58

def finish_message
  {
    job: {
      job_id: aker_job_id,
      updated_materials: updated_materials_message,
      new_materials: new_materials_message,
      containers: containers_message
    }
  }
end

#material_message(sample) ⇒ Object


38
39
40
# File 'app/models/aker/job.rb', line 38

def material_message(sample)
  Aker::Material.new(sample).attributes
end

#new_materialsObject


30
31
32
# File 'app/models/aker/job.rb', line 30

def new_materials
  []
end

#new_materials_messageObject


54
55
56
# File 'app/models/aker/job.rb', line 54

def new_materials_message
  new_materials.map { |m| material_message(m) }
end

#updated_materialsObject


26
27
28
# File 'app/models/aker/job.rb', line 26

def updated_materials
  samples
end

#updated_materials_messageObject


50
51
52
# File 'app/models/aker/job.rb', line 50

def updated_materials_message
  updated_materials.map { |m| material_message(m) }
end