Class: StateChangers::AutomaticLabwareStateChanger

Inherits:
DefaultStateChanger show all
Defined in:
app/models/state_changers.rb

Overview

Plate state changer to automatically complete specified work requests. This is the abstract version.

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from StateChangers::DefaultStateChanger

Instance Method Details

#complete_outstanding_requestsObject

rubocop:enable Style/OptionalBooleanParameter



98
99
100
101
102
103
104
# File 'app/models/state_changers.rb', line 98

def complete_outstanding_requests
  in_prog_submissions =
    v2_labware.in_progress_submission_uuids(request_type_to_complete: work_completion_request_type)
  return if in_prog_submissions.blank?

  api.work_completion.create!(submissions: in_prog_submissions, target: v2_labware.uuid, user: user_uuid)
end

#move_to!(state, reason = nil, customer_accepts_responsibility = false) ⇒ Object

rubocop:todo Style/OptionalBooleanParameter



91
92
93
94
# File 'app/models/state_changers.rb', line 91

def move_to!(state, reason = nil, customer_accepts_responsibility = false)
  super
  complete_outstanding_requests
end

#purpose_configObject



82
83
84
# File 'app/models/state_changers.rb', line 82

def purpose_config
  @purpose_config ||= Settings.purposes[purpose_uuid]
end

#purpose_uuidObject



78
79
80
# File 'app/models/state_changers.rb', line 78

def purpose_uuid
  @purpose_uuid ||= v2_labware.purpose.uuid
end

#v2_labwareObject



74
75
76
# File 'app/models/state_changers.rb', line 74

def v2_labware
  raise 'Must be implemented on subclass'
end

#work_completion_request_typeObject



86
87
88
# File 'app/models/state_changers.rb', line 86

def work_completion_request_type
  @work_completion_request_type ||= purpose_config[:work_completion_request_type]
end