Class: RecordLoader::DescriptorLoader

Inherits:
ApplicationRecordLoader show all
Defined in:
lib/record_loader/descriptor_loader.rb

Overview

Creates the specified Descriptor if they are not present Links the created task to the appropriate task and workflow if they exist. If the workflow or task is not found, it logs a warning and returns nil in development, staging, or cucumber environments.

Instance Method Summary collapse

Methods inherited from ApplicationRecordLoader

#wip_list

Instance Method Details

#create_or_update!(name, options) ⇒ Object

[View source]

16
17
18
19
20
21
22
23
# File 'lib/record_loader/descriptor_loader.rb', line 16

def create_or_update!(name, options)
  workflow_name = options.delete('workflow')
  workflow = Workflow.find_by!(name: workflow_name)
  task_name = options.delete('task')
  task = Task.find_by!(name: task_name, pipeline_workflow_id: workflow.id)
  options[:task_id] = task.id
  Descriptor.create_with(options).find_or_create_by!(name: name, task_id: task.id)
end