Class: RecordLoader::TaskLoader
- Inherits:
-
ApplicationRecordLoader
- Object
- Base
- ApplicationRecordLoader
- RecordLoader::TaskLoader
- Defined in:
- lib/record_loader/task_loader.rb
Overview
Creates the specified Task if they are not present
Instance Method Summary collapse
-
#create_or_update!(name, options) ⇒ Task?
Creates a Task with the given name and options.
Methods inherited from ApplicationRecordLoader
Instance Method Details
#create_or_update!(name, options) ⇒ Task?
Creates a Task with the given name and options. This method first retrieves the associated Workflow by its name. If the Workflow it logs a warning and returns nil
in development
, staging
, or cucumber
environments. In all other environments, it raises an ActiveRecord::RecordNotFound
exception. If the Workflow is found, it assigns its ID to the pipeline_workflow_id
attribute and creates or updates the Task.
development
, staging
, or cucumber
.
25 26 27 28 29 30 31 32 |
# File 'lib/record_loader/task_loader.rb', line 25 def create_or_update!(name, ) workflow_name = .delete('workflow') workflow = find_workflow!(workflow_name, name) return unless workflow [:pipeline_workflow_id] = workflow.id Task.create_with().find_or_create_by!(name: name, pipeline_workflow_id: workflow.id) end |