Module: RigidWorkflow::RunsHelper

Defined in:
app/helpers/rigid_workflow/runs_helper.rb

Overview

Serializes workflow runs to JSON for API responses.

Instance Method Summary collapse

Instance Method Details

#run_to_json(run) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/rigid_workflow/runs_helper.rb', line 5

def run_to_json(run)
  {
    workflow: {
      id: run.id,
      workflow_class: run.workflow_class,
      status: run.status,
      version: run.version,
      params: run.params,
      memory: run.memory,
      created_at: run.created_at,
      started_at: run.started_at,
      finished_at: run.finished_at
    },
    steps:
      run.steps.order(created_at: :asc).map { |step| serialize_step(step) },
    signals:
      run
        .signals
        .order(created_at: :asc)
        .map { |signal| serialize_signal(signal) }
  }
end