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 Squishify

extended

Instance Method Details

#as_json(_options = {}) ⇒ Object


17
18
19
# File 'app/models/aker/job.rb', line 17

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

#changed_containersObject


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

def changed_containers
  []
end

#container_message(_container) ⇒ Object


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

def container_message(_container)
  {}
end

#containers_messageObject


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

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

#finish_messageObject


53
54
55
56
57
58
59
60
61
62
# File 'app/models/aker/job.rb', line 53

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


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

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

#new_materialsObject


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

def new_materials
  []
end

#new_materials_messageObject


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

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

#updated_materialsObject


21
22
23
# File 'app/models/aker/job.rb', line 21

def updated_materials
  samples
end

#updated_materials_messageObject


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

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