decouplio 1.0.0alpha3 → 1.0.0alpha7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +11 -1
- data/.rubocop.yml +6 -0
- data/.ruby-version +1 -1
- data/README.md +2 -17
- data/decouplio.gemspec +4 -4
- data/lib/decouplio/action.rb +13 -3
- data/lib/decouplio/composer.rb +24 -3
- data/lib/decouplio/const/doby_aide_options.rb +1 -0
- data/lib/decouplio/const/error_messages.rb +9 -0
- data/lib/decouplio/const/step_options.rb +16 -0
- data/lib/decouplio/default_error_handler.rb +21 -6
- data/lib/decouplio/errors/execution_error.rb +20 -0
- data/lib/decouplio/errors/step_is_not_defined_for_pass_error.rb +27 -0
- data/lib/decouplio/logic_dsl.rb +52 -3
- data/lib/decouplio/options_validator.rb +46 -10
- data/lib/decouplio/steps/base_resq.rb +13 -3
- data/lib/decouplio/steps/service_fail.rb +4 -2
- data/lib/decouplio/steps/service_pass.rb +4 -2
- data/lib/decouplio/steps/service_step.rb +4 -2
- data/lib/decouplio/version.rb +1 -1
- metadata +14 -39
- data/docs/_config.yml +0 -1
- data/docs/aide.rb +0 -59
- data/docs/benchmarks.md +0 -1
- data/docs/context.md +0 -74
- data/docs/context.rb +0 -62
- data/docs/doby.rb +0 -38
- data/docs/doby_aide.md +0 -208
- data/docs/error_store.md +0 -347
- data/docs/error_store.rb +0 -202
- data/docs/fail.md +0 -1159
- data/docs/fail.rb +0 -859
- data/docs/index.md +0 -25
- data/docs/inner_action.md +0 -63
- data/docs/inner_action.rb +0 -43
- data/docs/logic_block.md +0 -29
- data/docs/octo.md +0 -326
- data/docs/octo.rb +0 -164
- data/docs/pass.md +0 -309
- data/docs/pass.rb +0 -213
- data/docs/quick_start.md +0 -71
- data/docs/quick_start.rb +0 -38
- data/docs/resq.md +0 -263
- data/docs/resq.rb +0 -176
- data/docs/step.md +0 -885
- data/docs/step.rb +0 -627
- data/docs/step_as_a_service.md +0 -123
- data/docs/step_as_a_service.rb +0 -77
- data/docs/wrap.md +0 -240
- data/docs/wrap.rb +0 -137
data/docs/step.md
DELETED
@@ -1,885 +0,0 @@
|
|
1
|
-
# Step
|
2
|
-
|
3
|
-
`step` is the basic type of `logic` steps
|
4
|
-
|
5
|
-
## Signature
|
6
|
-
|
7
|
-
```ruby
|
8
|
-
step(step_name, **options)
|
9
|
-
```
|
10
|
-
|
11
|
-
## Behavior
|
12
|
-
|
13
|
-
- when step method(`#step_one`) returns truthy value then it goes to success track(`step_two` step)
|
14
|
-
- when step method(#step_one) returns falsy value then it goes to failure track(`fail_one` step)
|
15
|
-
|
16
|
-
<details><summary><b>EXAMPLE (CLICK ME)</b></summary>
|
17
|
-
<p>
|
18
|
-
|
19
|
-
```ruby
|
20
|
-
require 'decouplio'
|
21
|
-
|
22
|
-
class SomeAction < Decouplio::Action
|
23
|
-
logic do
|
24
|
-
step :step_one
|
25
|
-
fail :fail_one
|
26
|
-
step :step_two
|
27
|
-
end
|
28
|
-
|
29
|
-
def step_one(param_for_step_one:, **)
|
30
|
-
param_for_step_one
|
31
|
-
end
|
32
|
-
|
33
|
-
def fail_one(**)
|
34
|
-
ctx[:action_failed] = true
|
35
|
-
end
|
36
|
-
|
37
|
-
def step_two(**)
|
38
|
-
ctx[:result] = 'Success'
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
success_action = SomeAction.call(param_for_step_one: true)
|
43
|
-
failure_action = SomeAction.call(param_for_step_one: false)
|
44
|
-
|
45
|
-
success_action # =>
|
46
|
-
# Result: success
|
47
|
-
|
48
|
-
# Railway Flow:
|
49
|
-
# step_one -> step_two
|
50
|
-
|
51
|
-
# Context:
|
52
|
-
# {:param_for_step_one=>true, :result=>"Success"}
|
53
|
-
|
54
|
-
# Errors:
|
55
|
-
# {}
|
56
|
-
|
57
|
-
failure_action # =>
|
58
|
-
# Result: failure
|
59
|
-
|
60
|
-
# Railway Flow:
|
61
|
-
# step_one -> fail_one
|
62
|
-
|
63
|
-
# Context:
|
64
|
-
# {:param_for_step_one=>false, :action_failed=>true}
|
65
|
-
|
66
|
-
# Errors:
|
67
|
-
# {}
|
68
|
-
```
|
69
|
-
|
70
|
-
```mermaid
|
71
|
-
flowchart LR
|
72
|
-
A(start)-->B(step_one);
|
73
|
-
B(step_one)-->|success track|C(step_two);
|
74
|
-
B(step_one)-->|failure track|D(fail_one);
|
75
|
-
C(step_two)-->|success track|E(finish_success);
|
76
|
-
D(fail_one)-->|failure track|F(finish_failure);
|
77
|
-
```
|
78
|
-
|
79
|
-
</p>
|
80
|
-
</details>
|
81
|
-
|
82
|
-
***
|
83
|
-
|
84
|
-
## Options
|
85
|
-
|
86
|
-
### on_success:
|
87
|
-
|Allowed values|Description|
|
88
|
-
|-|-|
|
89
|
-
|:finish_him|action stops execution if `step` method returns truthy value|
|
90
|
-
|symbol with next step name|step with specified symbol name performs if step method returns truthy value|
|
91
|
-
|:PASS|will direct execution flow to nearest success track step. If current step is the last step when action will finish as `success`|
|
92
|
-
|:FAIL|will direct execution flow to nearest failure track step. If current step is the last step when action will finish as `failure`|
|
93
|
-
|
94
|
-
### on_success: :finish_him
|
95
|
-
|
96
|
-
<details><summary><b>EXAMPLE (CLICK ME)</b></summary>
|
97
|
-
<p>
|
98
|
-
|
99
|
-
```ruby
|
100
|
-
require 'decouplio'
|
101
|
-
|
102
|
-
class SomeActionOnSuccessFinishHim < Decouplio::Action
|
103
|
-
logic do
|
104
|
-
step :step_one, on_success: :finish_him
|
105
|
-
fail :fail_one
|
106
|
-
step :step_two
|
107
|
-
end
|
108
|
-
|
109
|
-
def step_one(param_for_step_one:, **)
|
110
|
-
param_for_step_one
|
111
|
-
end
|
112
|
-
|
113
|
-
def fail_one(**)
|
114
|
-
ctx[:action_failed] = true
|
115
|
-
end
|
116
|
-
|
117
|
-
def step_two(**)
|
118
|
-
ctx[:result] = 'Success'
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
success_action = SomeActionOnSuccessFinishHim.call(param_for_step_one: true)
|
123
|
-
failure_action = SomeActionOnSuccessFinishHim.call(param_for_step_one: false)
|
124
|
-
success_action # =>
|
125
|
-
# Result: success
|
126
|
-
|
127
|
-
# Railway Flow:
|
128
|
-
# step_one
|
129
|
-
|
130
|
-
# Context:
|
131
|
-
# {:param_for_step_one=>true}
|
132
|
-
|
133
|
-
# Errors:
|
134
|
-
# {}
|
135
|
-
|
136
|
-
failure_action # =>
|
137
|
-
# Result: failure
|
138
|
-
|
139
|
-
# Railway Flow:
|
140
|
-
# step_one -> fail_one
|
141
|
-
|
142
|
-
# Context:
|
143
|
-
# {:param_for_step_one=>false, :action_failed=>true}
|
144
|
-
|
145
|
-
# Errors:
|
146
|
-
# {}
|
147
|
-
```
|
148
|
-
|
149
|
-
```mermaid
|
150
|
-
flowchart LR
|
151
|
-
1(start)-->2(step_one);
|
152
|
-
2(step_one)-->|success track|3(finish_success);
|
153
|
-
2(step_one)-->|failure track|4(fail_one);
|
154
|
-
4(fail_one)-->|failure track|5(finish_failure);
|
155
|
-
```
|
156
|
-
</p>
|
157
|
-
</details>
|
158
|
-
|
159
|
-
***
|
160
|
-
|
161
|
-
### on_success: next success track step
|
162
|
-
|
163
|
-
<details><summary><b>EXAMPLE (CLICK ME)</b></summary>
|
164
|
-
<p>
|
165
|
-
|
166
|
-
```ruby
|
167
|
-
require 'decouplio'
|
168
|
-
|
169
|
-
class SomeActionOnSuccessToSuccessTrack < Decouplio::Action
|
170
|
-
logic do
|
171
|
-
step :step_one, on_success: :step_three
|
172
|
-
fail :fail_one
|
173
|
-
step :step_two
|
174
|
-
step :step_three
|
175
|
-
end
|
176
|
-
|
177
|
-
def step_one(param_for_step_one:, **)
|
178
|
-
param_for_step_one
|
179
|
-
end
|
180
|
-
|
181
|
-
def fail_one(**)
|
182
|
-
ctx[:action_failed] = true
|
183
|
-
end
|
184
|
-
|
185
|
-
def step_two(**)
|
186
|
-
ctx[:step_two] = 'Success'
|
187
|
-
end
|
188
|
-
|
189
|
-
def step_three(**)
|
190
|
-
ctx[:result] = 'Result'
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
success_action = SomeActionOnSuccessToSuccessTrack.call(param_for_step_one: true)
|
195
|
-
failure_action = SomeActionOnSuccessToSuccessTrack.call(param_for_step_one: false)
|
196
|
-
success_action # =>
|
197
|
-
# Result: success
|
198
|
-
|
199
|
-
# Railway Flow:
|
200
|
-
# step_one -> step_three
|
201
|
-
|
202
|
-
# Context:
|
203
|
-
# {:param_for_step_one=>true, :result=>"Result"}
|
204
|
-
|
205
|
-
# Errors:
|
206
|
-
# {}
|
207
|
-
|
208
|
-
failure_action # =>
|
209
|
-
# Result: failure
|
210
|
-
|
211
|
-
# Railway Flow:
|
212
|
-
# step_one -> fail_one
|
213
|
-
|
214
|
-
# Context:
|
215
|
-
# {:param_for_step_one=>false, :action_failed=>true}
|
216
|
-
|
217
|
-
# Errors:
|
218
|
-
# {}
|
219
|
-
```
|
220
|
-
|
221
|
-
```mermaid
|
222
|
-
flowchart LR
|
223
|
-
A(start)-->B(step_one);
|
224
|
-
B(step_one)-->|success track|C(step_three);
|
225
|
-
B(step_one)-->|failure track|D(fail_one);
|
226
|
-
C(step_three)-->|success track|E(finish_success);
|
227
|
-
D(fail_one)-->|failure track|F(finish_failure);
|
228
|
-
```
|
229
|
-
|
230
|
-
</p>
|
231
|
-
</details>
|
232
|
-
|
233
|
-
***
|
234
|
-
|
235
|
-
### on_success: next failure track step
|
236
|
-
|
237
|
-
Can be used if for some reason you need to jump to fail step
|
238
|
-
|
239
|
-
<details><summary><b>EXAMPLE (CLICK ME)</b></summary>
|
240
|
-
<p>
|
241
|
-
|
242
|
-
```ruby
|
243
|
-
require 'decouplio'
|
244
|
-
|
245
|
-
class SomeActionOnSuccessToFailureTrack < Decouplio::Action
|
246
|
-
logic do
|
247
|
-
step :step_one, on_success: :fail_two
|
248
|
-
fail :fail_one
|
249
|
-
step :step_two
|
250
|
-
step :step_three
|
251
|
-
fail :fail_two
|
252
|
-
end
|
253
|
-
|
254
|
-
def step_one(param_for_step_one:, **)
|
255
|
-
param_for_step_one
|
256
|
-
end
|
257
|
-
|
258
|
-
def fail_one(**)
|
259
|
-
ctx[:action_failed] = true
|
260
|
-
end
|
261
|
-
|
262
|
-
def step_two(**)
|
263
|
-
ctx[:step_two] = 'Success'
|
264
|
-
end
|
265
|
-
|
266
|
-
def step_three(**)
|
267
|
-
ctx[:result] = 'Result'
|
268
|
-
end
|
269
|
-
|
270
|
-
def fail_two(**)
|
271
|
-
ctx[:fail_two] = 'Failure'
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
|
-
success_action = SomeActionOnSuccessToFailureTrack.call(param_for_step_one: true)
|
276
|
-
failure_action = SomeActionOnSuccessToFailureTrack.call(param_for_step_one: false)
|
277
|
-
success_action # =>
|
278
|
-
# Result: failure
|
279
|
-
|
280
|
-
# Railway Flow:
|
281
|
-
# step_one -> fail_two
|
282
|
-
|
283
|
-
# Context:
|
284
|
-
# {:param_for_step_one=>true, :fail_two=>"Failure"}
|
285
|
-
|
286
|
-
# Errors:
|
287
|
-
# {}
|
288
|
-
|
289
|
-
failure_action # =>
|
290
|
-
# Result: failure
|
291
|
-
|
292
|
-
# Railway Flow:
|
293
|
-
# step_one -> fail_one -> fail_two
|
294
|
-
|
295
|
-
# Context:
|
296
|
-
# {:param_for_step_one=>false, :action_failed=>true, :fail_two=>"Failure"}
|
297
|
-
|
298
|
-
# Errors:
|
299
|
-
# {}
|
300
|
-
```
|
301
|
-
|
302
|
-
```mermaid
|
303
|
-
flowchart LR
|
304
|
-
A(start)-->B(step_one);
|
305
|
-
B(step_one)-->|success track|C(fail_two);
|
306
|
-
B(step_one)-->|failure track|D(fail_one);
|
307
|
-
C(fail_two)-->|success track|E(finish_failure);
|
308
|
-
D(fail_one)-->|failure track|C(fail_two);
|
309
|
-
C(fail_two)-->|failure track|E(finish_failure);
|
310
|
-
```
|
311
|
-
|
312
|
-
</p>
|
313
|
-
</details>
|
314
|
-
|
315
|
-
***
|
316
|
-
|
317
|
-
### on_success: :PASS
|
318
|
-
It will perform like regular `step`, just move to next success track step.
|
319
|
-
|
320
|
-
### on_success: :FAIL
|
321
|
-
<details><summary><b>EXAMPLE (CLICK ME)</b></summary>
|
322
|
-
<p>
|
323
|
-
|
324
|
-
```ruby
|
325
|
-
require 'decouplio'
|
326
|
-
|
327
|
-
class SomeActionOnSuccessFail < Decouplio::Action
|
328
|
-
logic do
|
329
|
-
step :step_one
|
330
|
-
step :step_two, on_success: :FAIL
|
331
|
-
end
|
332
|
-
|
333
|
-
def step_one(**)
|
334
|
-
ctx[:step_one] = 'Success'
|
335
|
-
end
|
336
|
-
|
337
|
-
def step_two(step_two_param:, **)
|
338
|
-
ctx[:step_two] = step_two_param
|
339
|
-
end
|
340
|
-
end
|
341
|
-
|
342
|
-
success_action = SomeActionOnSuccessFail.call(step_two_param: true)
|
343
|
-
failure_action = SomeActionOnSuccessFail.call(step_two_param: false)
|
344
|
-
|
345
|
-
success_action # =>
|
346
|
-
# Result: failure
|
347
|
-
|
348
|
-
# Railway Flow:
|
349
|
-
# step_one -> step_two
|
350
|
-
|
351
|
-
# Context:
|
352
|
-
# :step_two_param => true
|
353
|
-
# :step_one => "Success"
|
354
|
-
# :step_two => true
|
355
|
-
|
356
|
-
# Errors:
|
357
|
-
# {}
|
358
|
-
|
359
|
-
failure_action # =>
|
360
|
-
# Result: failure
|
361
|
-
|
362
|
-
# Railway Flow:
|
363
|
-
# step_one -> step_two
|
364
|
-
|
365
|
-
# Context:
|
366
|
-
# :step_two_param => false
|
367
|
-
# :step_one => "Success"
|
368
|
-
# :step_two => false
|
369
|
-
|
370
|
-
# Errors:
|
371
|
-
# {}
|
372
|
-
```
|
373
|
-
|
374
|
-
```mermaid
|
375
|
-
flowchart LR
|
376
|
-
1(start)-->2(step_one);
|
377
|
-
2(step_one)-->|success track|3(step_two);
|
378
|
-
3(step_two)-->|success track|4(finish_failure);
|
379
|
-
3(step_two)-->|failure track|4(finish_failure);
|
380
|
-
```
|
381
|
-
</p>
|
382
|
-
</details>
|
383
|
-
|
384
|
-
***
|
385
|
-
|
386
|
-
|
387
|
-
### on_failure:
|
388
|
-
|Allowed values|Description|
|
389
|
-
|-|-|
|
390
|
-
|:finish_him|action stops execution if `step` method returns falsy value|
|
391
|
-
|symbol with next step name|step with specified symbol name performs if step method returns falsy value|
|
392
|
-
|:PASS|will direct execution flow to nearest success track step. If current step is the last step when action will finish as `success`|
|
393
|
-
|:FAIL|will direct execution flow to nearest failure track step. If current step is the last step when action will finish as `failure`|
|
394
|
-
|
395
|
-
### on_failure: :finish_him
|
396
|
-
|
397
|
-
<details><summary><b>EXAMPLE (CLICK ME)</b></summary>
|
398
|
-
<p>
|
399
|
-
|
400
|
-
```ruby
|
401
|
-
require 'decouplio'
|
402
|
-
|
403
|
-
class SomeActionOnFailureFinishHim < Decouplio::Action
|
404
|
-
logic do
|
405
|
-
step :step_one, on_failure: :finish_him
|
406
|
-
fail :fail_one
|
407
|
-
step :step_two
|
408
|
-
fail :fail_two
|
409
|
-
end
|
410
|
-
|
411
|
-
def step_one(param_for_step_one:, **)
|
412
|
-
param_for_step_one
|
413
|
-
end
|
414
|
-
|
415
|
-
def fail_one(**)
|
416
|
-
ctx[:action_failed] = true
|
417
|
-
end
|
418
|
-
|
419
|
-
def step_two(**)
|
420
|
-
ctx[:result] = 'Success'
|
421
|
-
end
|
422
|
-
|
423
|
-
def fail_two(**)
|
424
|
-
ctx[:fail_two] = 'failure'
|
425
|
-
end
|
426
|
-
end
|
427
|
-
|
428
|
-
success_action = SomeActionOnFailureFinishHim.call(param_for_step_one: true)
|
429
|
-
failure_action = SomeActionOnFailureFinishHim.call(param_for_step_one: false)
|
430
|
-
success_action # =>
|
431
|
-
# Result: success
|
432
|
-
|
433
|
-
# Railway Flow:
|
434
|
-
# step_one -> step_two
|
435
|
-
|
436
|
-
# Context:
|
437
|
-
# {:param_for_step_one=>true, :result=>"Success"}
|
438
|
-
|
439
|
-
# Errors:
|
440
|
-
# {}
|
441
|
-
|
442
|
-
failure_action # =>
|
443
|
-
# Result: failure
|
444
|
-
|
445
|
-
# Railway Flow:
|
446
|
-
# step_one
|
447
|
-
|
448
|
-
# Context:
|
449
|
-
# {:param_for_step_one=>false}
|
450
|
-
|
451
|
-
# Errors:
|
452
|
-
# {}
|
453
|
-
```
|
454
|
-
|
455
|
-
```mermaid
|
456
|
-
flowchart LR
|
457
|
-
1(start)-->2(step_one);
|
458
|
-
2(step_one)-->|success track|3(step_two);
|
459
|
-
3(step_two)-->|success track|5(finish_success);
|
460
|
-
2(step_one)-->|failure track|4(finish_failure);
|
461
|
-
```
|
462
|
-
</p>
|
463
|
-
</details>
|
464
|
-
|
465
|
-
***
|
466
|
-
|
467
|
-
### on_failure: next success track step
|
468
|
-
|
469
|
-
Can be used in case if you need to come back to success track
|
470
|
-
|
471
|
-
<details><summary><b>EXAMPLE (CLICK ME)</b></summary>
|
472
|
-
<p>
|
473
|
-
|
474
|
-
```ruby
|
475
|
-
require 'decouplio'
|
476
|
-
|
477
|
-
class SomeActionOnFailureToSuccessTrack < Decouplio::Action
|
478
|
-
logic do
|
479
|
-
step :step_one, on_failure: :step_three
|
480
|
-
fail :fail_one
|
481
|
-
step :step_two
|
482
|
-
fail :fail_two
|
483
|
-
step :step_three
|
484
|
-
end
|
485
|
-
|
486
|
-
def step_one(param_for_step_one:, **)
|
487
|
-
param_for_step_one
|
488
|
-
end
|
489
|
-
|
490
|
-
def fail_one(**)
|
491
|
-
ctx[:action_failed] = true
|
492
|
-
end
|
493
|
-
|
494
|
-
def step_two(**)
|
495
|
-
ctx[:result] = 'Success'
|
496
|
-
end
|
497
|
-
|
498
|
-
def fail_two(**)
|
499
|
-
ctx[:fail_two] = 'failure'
|
500
|
-
end
|
501
|
-
|
502
|
-
def step_three(**)
|
503
|
-
ctx[:step_three] = 'Success'
|
504
|
-
end
|
505
|
-
end
|
506
|
-
|
507
|
-
success_action = SomeActionOnFailureToSuccessTrack.call(param_for_step_one: true)
|
508
|
-
failure_action = SomeActionOnFailureToSuccessTrack.call(param_for_step_one: false)
|
509
|
-
success_action # =>
|
510
|
-
# Result: success
|
511
|
-
|
512
|
-
# Railway Flow:
|
513
|
-
# step_one -> step_two -> step_three
|
514
|
-
|
515
|
-
# Context:
|
516
|
-
# {:param_for_step_one=>true, :result=>"Success", :step_three=>"Success"}
|
517
|
-
|
518
|
-
# Errors:
|
519
|
-
# {}
|
520
|
-
|
521
|
-
|
522
|
-
failure_action # =>
|
523
|
-
# Result: success
|
524
|
-
|
525
|
-
# Railway Flow:
|
526
|
-
# step_one -> step_three
|
527
|
-
|
528
|
-
# Context:
|
529
|
-
# {:param_for_step_one=>false, :step_three=>"Success"}
|
530
|
-
|
531
|
-
# Errors:
|
532
|
-
# {}
|
533
|
-
```
|
534
|
-
|
535
|
-
```mermaid
|
536
|
-
flowchart LR
|
537
|
-
1(start)-->2(step_one);
|
538
|
-
2(step_one)-->|success track|3(step_two);
|
539
|
-
3(step_two)-->|success track|4(step_three);
|
540
|
-
4(step_three)-->|success track|5(finish_success);
|
541
|
-
2(step_one)-->|failure track|4(step_three);
|
542
|
-
```
|
543
|
-
</p>
|
544
|
-
</details>
|
545
|
-
|
546
|
-
***
|
547
|
-
|
548
|
-
### on_failure: next failure track step
|
549
|
-
|
550
|
-
<details><summary><b>EXAMPLE (CLICK ME)</b></summary>
|
551
|
-
<p>
|
552
|
-
|
553
|
-
```ruby
|
554
|
-
require 'decouplio'
|
555
|
-
|
556
|
-
class SomeActionOnFailureToFailureTrack < Decouplio::Action
|
557
|
-
logic do
|
558
|
-
step :step_one, on_failure: :fail_two
|
559
|
-
fail :fail_one
|
560
|
-
step :step_two
|
561
|
-
fail :fail_two
|
562
|
-
step :step_three
|
563
|
-
end
|
564
|
-
|
565
|
-
def step_one(param_for_step_one:, **)
|
566
|
-
param_for_step_one
|
567
|
-
end
|
568
|
-
|
569
|
-
def fail_one(**)
|
570
|
-
ctx[:action_failed] = true
|
571
|
-
end
|
572
|
-
|
573
|
-
def step_two(**)
|
574
|
-
ctx[:result] = 'Success'
|
575
|
-
end
|
576
|
-
|
577
|
-
def fail_two(**)
|
578
|
-
ctx[:fail_two] = 'failure'
|
579
|
-
end
|
580
|
-
|
581
|
-
def step_three(**)
|
582
|
-
ctx[:step_three] = 'Success'
|
583
|
-
end
|
584
|
-
end
|
585
|
-
|
586
|
-
success_action = SomeActionOnFailureToFailureTrack.call(param_for_step_one: true)
|
587
|
-
failure_action = SomeActionOnFailureToFailureTrack.call(param_for_step_one: false)
|
588
|
-
success_action # =>
|
589
|
-
# Result: success
|
590
|
-
|
591
|
-
# Railway Flow:
|
592
|
-
# step_one -> step_two -> step_three
|
593
|
-
|
594
|
-
# Context:
|
595
|
-
# {:param_for_step_one=>true, :result=>"Success", :step_three=>"Success"}
|
596
|
-
|
597
|
-
# Errors:
|
598
|
-
# {}
|
599
|
-
|
600
|
-
failure_action # =>
|
601
|
-
# Result: failure
|
602
|
-
|
603
|
-
# Railway Flow:
|
604
|
-
# step_one -> fail_two
|
605
|
-
|
606
|
-
# Context:
|
607
|
-
# {:param_for_step_one=>false, :fail_two=>"failure"}
|
608
|
-
|
609
|
-
# Errors:
|
610
|
-
# {}
|
611
|
-
```
|
612
|
-
|
613
|
-
```mermaid
|
614
|
-
flowchart LR
|
615
|
-
1(start)-->2(step_one);
|
616
|
-
2(step_one)-->|success track|3(step_two);
|
617
|
-
3(step_two)-->|success track|4(step_three);
|
618
|
-
4(step_three)-->|success track|5(finish_success);
|
619
|
-
2(step_one)-->|failure track|6(fail_two);
|
620
|
-
6(fail_two)-->|failure track|7(finish_failure);
|
621
|
-
```
|
622
|
-
</p>
|
623
|
-
</details>
|
624
|
-
|
625
|
-
***
|
626
|
-
|
627
|
-
### on_failure: :PASS
|
628
|
-
<details><summary><b>EXAMPLE (CLICK ME)</b></summary>
|
629
|
-
<p>
|
630
|
-
|
631
|
-
```ruby
|
632
|
-
require 'decouplio'
|
633
|
-
|
634
|
-
class SomeActionOnFailurePass < Decouplio::Action
|
635
|
-
logic do
|
636
|
-
step :step_one
|
637
|
-
step :step_two, on_failure: :PASS
|
638
|
-
end
|
639
|
-
|
640
|
-
def step_one(**)
|
641
|
-
ctx[:step_one] = true
|
642
|
-
end
|
643
|
-
|
644
|
-
def step_two(step_two_param:, **)
|
645
|
-
ctx[:step_two] = step_two_param
|
646
|
-
end
|
647
|
-
end
|
648
|
-
|
649
|
-
|
650
|
-
success_action = SomeActionOnFailurePass.call(step_two_param: true)
|
651
|
-
failure_action = SomeActionOnFailurePass.call(step_two_param: false)
|
652
|
-
|
653
|
-
success_action # =>
|
654
|
-
# Result: success
|
655
|
-
|
656
|
-
# Railway Flow:
|
657
|
-
# step_one -> step_two
|
658
|
-
|
659
|
-
# Context:
|
660
|
-
# :step_two_param => true
|
661
|
-
# :step_one => true
|
662
|
-
# :step_two => true
|
663
|
-
|
664
|
-
# Errors:
|
665
|
-
# {}
|
666
|
-
|
667
|
-
failure_action # =>
|
668
|
-
# Result: success
|
669
|
-
|
670
|
-
# Railway Flow:
|
671
|
-
# step_one -> step_two
|
672
|
-
|
673
|
-
# Context:
|
674
|
-
# :step_two_param => false
|
675
|
-
# :step_one => true
|
676
|
-
# :step_two => false
|
677
|
-
|
678
|
-
# Errors:
|
679
|
-
# {}
|
680
|
-
|
681
|
-
```
|
682
|
-
|
683
|
-
```mermaid
|
684
|
-
flowchart LR
|
685
|
-
1(start)-->2(step_one);
|
686
|
-
2(step_one)-->|success track|3(step_two);
|
687
|
-
3(step_two)-->|success track|4(finish_success);
|
688
|
-
3(step_two)-->|failure track|4(finish_success);
|
689
|
-
```
|
690
|
-
</p>
|
691
|
-
</details>
|
692
|
-
|
693
|
-
***
|
694
|
-
|
695
|
-
|
696
|
-
### on_failure: :FAIL
|
697
|
-
It will perform like regular `step`, just move to next failure track step.
|
698
|
-
|
699
|
-
***
|
700
|
-
|
701
|
-
### if: condition method name
|
702
|
-
Can be used in case if for some reason step shouldn't be executed
|
703
|
-
|
704
|
-
<details><summary><b>EXAMPLE (CLICK ME)</b></summary>
|
705
|
-
<p>
|
706
|
-
|
707
|
-
```ruby
|
708
|
-
require 'decouplio'
|
709
|
-
|
710
|
-
class SomeActionOnIfCondition < Decouplio::Action
|
711
|
-
logic do
|
712
|
-
step :step_one
|
713
|
-
fail :fail_one
|
714
|
-
step :step_two
|
715
|
-
fail :fail_two
|
716
|
-
step :step_three, if: :step_condition?
|
717
|
-
end
|
718
|
-
|
719
|
-
def step_one(param_for_step_one:, **)
|
720
|
-
param_for_step_one
|
721
|
-
end
|
722
|
-
|
723
|
-
def fail_one(**)
|
724
|
-
ctx[:action_failed] = true
|
725
|
-
end
|
726
|
-
|
727
|
-
def step_two(**)
|
728
|
-
ctx[:result] = 'Success'
|
729
|
-
end
|
730
|
-
|
731
|
-
def fail_two(**)
|
732
|
-
ctx[:fail_two] = 'failure'
|
733
|
-
end
|
734
|
-
|
735
|
-
def step_three(**)
|
736
|
-
ctx[:step_three] = 'Success'
|
737
|
-
end
|
738
|
-
|
739
|
-
def step_condition?(step_condition_param:, **)
|
740
|
-
step_condition_param
|
741
|
-
end
|
742
|
-
end
|
743
|
-
|
744
|
-
condition_positive = SomeActionOnIfCondition.call(
|
745
|
-
param_for_step_one: true,
|
746
|
-
step_condition_param: true
|
747
|
-
)
|
748
|
-
condition_negative = SomeActionOnIfCondition.call(
|
749
|
-
param_for_step_one: true,
|
750
|
-
step_condition_param: false
|
751
|
-
)
|
752
|
-
condition_positive # =>
|
753
|
-
# Result: success
|
754
|
-
|
755
|
-
# Railway Flow:
|
756
|
-
# step_one -> step_two -> step_three
|
757
|
-
|
758
|
-
# Context:
|
759
|
-
# {:param_for_step_one=>true, :step_condition_param=>true, :result=>"Success", :step_three=>"Success"}
|
760
|
-
|
761
|
-
# Errors:
|
762
|
-
# {}
|
763
|
-
|
764
|
-
condition_negative # =>
|
765
|
-
# Result: success
|
766
|
-
|
767
|
-
# Railway Flow:
|
768
|
-
# step_one -> step_two
|
769
|
-
|
770
|
-
# Context:
|
771
|
-
# {:param_for_step_one=>true, :step_condition_param=>false, :result=>"Success"}
|
772
|
-
|
773
|
-
# Errors:
|
774
|
-
# {}
|
775
|
-
```
|
776
|
-
|
777
|
-
```mermaid
|
778
|
-
flowchart LR
|
779
|
-
1(start)-->2(step_one);
|
780
|
-
2(step_one)-->|condition positive|3(step_two);
|
781
|
-
3(step_two)-->|condition positive|4(step_three);
|
782
|
-
4(step_three)-->|condition positive|5(finish_success);
|
783
|
-
2(step_one)-->|condition negative|6(step_two);
|
784
|
-
6(step_two)-->|condition negative|7(finish_success);
|
785
|
-
```
|
786
|
-
</p>
|
787
|
-
</details>
|
788
|
-
|
789
|
-
***
|
790
|
-
|
791
|
-
### unless: condition method name
|
792
|
-
Can be used in case if for some reason step shouldn't be executed
|
793
|
-
|
794
|
-
<details><summary><b>EXAMPLE (CLICK ME)</b></summary>
|
795
|
-
<p>
|
796
|
-
|
797
|
-
```ruby
|
798
|
-
require 'decouplio'
|
799
|
-
|
800
|
-
class SomeActionOnUnlessCondition < Decouplio::Action
|
801
|
-
logic do
|
802
|
-
step :step_one
|
803
|
-
fail :fail_one
|
804
|
-
step :step_two
|
805
|
-
fail :fail_two
|
806
|
-
step :step_three, unless: :step_condition?
|
807
|
-
end
|
808
|
-
|
809
|
-
def step_one(param_for_step_one:, **)
|
810
|
-
param_for_step_one
|
811
|
-
end
|
812
|
-
|
813
|
-
def fail_one(**)
|
814
|
-
ctx[:action_failed] = true
|
815
|
-
end
|
816
|
-
|
817
|
-
def step_two(**)
|
818
|
-
ctx[:result] = 'Success'
|
819
|
-
end
|
820
|
-
|
821
|
-
def fail_two(**)
|
822
|
-
ctx[:fail_two] = 'failure'
|
823
|
-
end
|
824
|
-
|
825
|
-
def step_three(**)
|
826
|
-
ctx[:step_three] = 'Success'
|
827
|
-
end
|
828
|
-
|
829
|
-
def step_condition?(step_condition_param:, **)
|
830
|
-
step_condition_param
|
831
|
-
end
|
832
|
-
end
|
833
|
-
|
834
|
-
condition_positive = SomeActionOnUnlessCondition.call(
|
835
|
-
param_for_step_one: true,
|
836
|
-
step_condition_param: true
|
837
|
-
)
|
838
|
-
condition_negative = SomeActionOnUnlessCondition.call(
|
839
|
-
param_for_step_one: true,
|
840
|
-
step_condition_param: false
|
841
|
-
)
|
842
|
-
condition_positive # =>
|
843
|
-
# Result: success
|
844
|
-
|
845
|
-
# Railway Flow:
|
846
|
-
# step_one -> step_two
|
847
|
-
|
848
|
-
# Context:
|
849
|
-
# {:param_for_step_one=>true, :step_condition_param=>true, :result=>"Success"}
|
850
|
-
|
851
|
-
# Errors:
|
852
|
-
# {}
|
853
|
-
|
854
|
-
condition_negative # =>
|
855
|
-
# Result: success
|
856
|
-
|
857
|
-
# Railway Flow:
|
858
|
-
# step_one -> step_two -> step_three
|
859
|
-
|
860
|
-
# Context:
|
861
|
-
# {:param_for_step_one=>true, :step_condition_param=>false, :result=>"Success", :step_three=>"Success"}
|
862
|
-
|
863
|
-
# Errors:
|
864
|
-
# {}
|
865
|
-
```
|
866
|
-
|
867
|
-
```mermaid
|
868
|
-
flowchart LR
|
869
|
-
1(start)-->2(step_one);
|
870
|
-
2(step_one)-->|condition positive|3(step_two);
|
871
|
-
3(step_two)-->|condition positive|4(finish_success);
|
872
|
-
2(step_one)-->|condition negative|5(step_two);
|
873
|
-
5(step_two)-->|condition negative|6(step_three);
|
874
|
-
6(step_three)-->|condition negative|7(finish_success);
|
875
|
-
```
|
876
|
-
</p>
|
877
|
-
</details>
|
878
|
-
|
879
|
-
***
|
880
|
-
|
881
|
-
### finish_him: :on_success
|
882
|
-
The same behavior as for `on_success: :finish_him`
|
883
|
-
|
884
|
-
### finish_him: :on_failure
|
885
|
-
The same behavior as for `on_failure: :finish_him`
|