forked from cweatureapps/SwiftScraper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
StepFlowResult.swift
38 lines (32 loc) · 1.09 KB
/
StepFlowResult.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// StepFlowResult.swift
// SwiftScraper
//
// Created by Ken Ko on 28/04/2017.
// Copyright © 2017 Ken Ko. All rights reserved.
//
import Foundation
/// Result which defines control flow of the steps.
public enum StepFlowResult {
/// Proceed to the next step.
case proceed
/// Jump to the step at the given index in the `Step` array and continue execution from there.
case jumpToStep(Int)
/// StepRunnerState stops executing, and finishes immediately with a state of `StepRunnerState.success`.
case finish
/// StepRunnerState stops executing, and finishes immediately with a state of `StepRunnerState.failure`.
case failure(Error)
/// Converts to a StepCompletionResult.
func convertToStepCompletionResult(with model: JSON) -> StepCompletionResult {
switch self {
case .proceed:
return .proceed(model)
case .finish:
return .finish(model)
case .jumpToStep(let step):
return .jumpToStep(step, model)
case .failure(let error):
return .failure(error, model)
}
}
}