Class: RecordLoader::FlowcellTypeRequestTypeLoader
- Inherits:
-
ApplicationRecordLoader
- Object
- Base
- ApplicationRecordLoader
- RecordLoader::FlowcellTypeRequestTypeLoader
- Defined in:
- lib/record_loader/flowcell_type_request_type_loader.rb
Overview
Creates the specified flowcelltype_request_types types if they are not present. They require a flowcell type name and a request type key
Instance Method Summary collapse
- #create_or_update!(_name, options) ⇒ Object
- #flowcell_type(flowcell_type_name) ⇒ Object
- #request_type(request_type_key) ⇒ Object
Methods inherited from ApplicationRecordLoader
Instance Method Details
#create_or_update!(_name, options) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/record_loader/flowcell_type_request_type_loader.rb', line 23 def create_or_update!(_name, ) obj = .dup ft = flowcell_type(obj.delete('flowcell_type_name')) rt = request_type(obj.delete('request_type_key')) return unless ft&.id && rt&.id FlowcellTypesRequestType.create_with( obj.merge(flowcell_type_id: ft&.id, request_type_id: rt&.id) ).find_or_create_by!(flowcell_type_id: ft&.id) end |
#flowcell_type(flowcell_type_name) ⇒ Object
13 14 15 16 |
# File 'lib/record_loader/flowcell_type_request_type_loader.rb', line 13 def flowcell_type(flowcell_type_name) raise 'Flowcell type name not defined' if flowcell_type_name.nil? FlowcellType.find_by(name: flowcell_type_name) end |
#request_type(request_type_key) ⇒ Object
18 19 20 21 |
# File 'lib/record_loader/flowcell_type_request_type_loader.rb', line 18 def request_type(request_type_key) raise 'RequestType key not defined' if request_type_key.nil? RequestType.find_by(key: request_type_key) end |