decouplio 1.0.0alpha → 1.0.0alpha3
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/.rubocop.yml +4 -0
- data/README.md +26 -2
- data/benchmarks/Gemfile +2 -1
- data/benchmarks/multi_step_benchmark.rb +336 -0
- data/benchmarks/single_step_benchmark.rb +159 -0
- data/decouplio.gemspec +1 -1
- data/docker-compose.yml +13 -2
- data/docs/aide.rb +59 -0
- data/docs/doby.rb +1 -1
- data/docs/doby_aide.md +208 -0
- data/docs/fail.md +143 -0
- data/docs/fail.rb +126 -29
- data/docs/index.md +1 -1
- data/docs/logic_block.md +4 -0
- data/docs/octo.md +59 -2
- data/docs/quick_start.md +1 -1
- data/docs/resq.md +2 -2
- data/docs/step.md +148 -0
- data/docs/step.rb +119 -18
- data/docs/step_as_a_service.md +25 -11
- data/docs/step_as_a_service.rb +2 -2
- data/docs/wrap.md +8 -0
- data/lib/decouplio/action.rb +22 -3
- data/lib/decouplio/composer.rb +91 -20
- data/lib/decouplio/const/doby_aide_options.rb +15 -0
- data/lib/decouplio/const/reserved_methods.rb +13 -9
- data/lib/decouplio/const/results.rb +2 -0
- data/lib/decouplio/const/types.rb +19 -5
- data/lib/decouplio/const/validations/aide.rb +38 -0
- data/lib/decouplio/const/validations/doby.rb +36 -0
- data/lib/decouplio/const/validations/fail.rb +5 -1
- data/lib/decouplio/const/validations/octo.rb +2 -1
- data/lib/decouplio/errors/aide_can_not_be_first_step_error.rb +18 -0
- data/lib/decouplio/errors/aide_controversial_keys_error.rb +26 -0
- data/lib/decouplio/errors/aide_finish_him_error.rb +26 -0
- data/lib/decouplio/errors/doby_controversial_keys_error.rb +26 -0
- data/lib/decouplio/errors/doby_finish_him_error.rb +26 -0
- data/lib/decouplio/errors/{fail_is_first_step_error.rb → fail_can_not_be_first_step_error.rb} +1 -1
- data/lib/decouplio/errors/step_is_not_defined_for_aide_error.rb +26 -0
- data/lib/decouplio/errors/step_is_not_defined_for_doby_error.rb +27 -0
- data/lib/decouplio/logic_dsl.rb +30 -3
- data/lib/decouplio/options_validator.rb +122 -8
- data/lib/decouplio/steps/aide.rb +37 -0
- data/lib/decouplio/steps/doby.rb +14 -9
- data/lib/decouplio/steps/fail.rb +7 -22
- data/lib/decouplio/steps/inner_action_fail.rb +7 -22
- data/lib/decouplio/steps/inner_action_step.rb +7 -18
- data/lib/decouplio/steps/octo.rb +7 -2
- data/lib/decouplio/steps/service_fail.rb +11 -23
- data/lib/decouplio/steps/service_pass.rb +4 -1
- data/lib/decouplio/steps/service_step.rb +11 -19
- data/lib/decouplio/steps/shared/fail_resolver.rb +40 -0
- data/lib/decouplio/steps/shared/step_resolver.rb +43 -0
- data/lib/decouplio/steps/step.rb +7 -18
- data/lib/decouplio/steps/wrap.rb +7 -18
- data/lib/decouplio/validators/condition.rb +10 -0
- data/lib/decouplio/version.rb +1 -1
- metadata +22 -7
- data/benchmarks/benchmarks.rb +0 -527
- data/docs/doby.md +0 -80
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base_error'
|
4
|
+
require_relative '../const/validations/doby'
|
5
|
+
require_relative '../const/validations/common'
|
6
|
+
|
7
|
+
module Decouplio
|
8
|
+
module Errors
|
9
|
+
class StepIsNotDefinedForDobyError < Decouplio::Errors::BaseError
|
10
|
+
def template
|
11
|
+
Decouplio::Const::Validations::Doby::VALIDATION_ERROR_MESSAGE
|
12
|
+
end
|
13
|
+
|
14
|
+
def interpolation_values
|
15
|
+
[
|
16
|
+
@errored_option,
|
17
|
+
format(
|
18
|
+
Decouplio::Const::Validations::Common::STEP_IS_NOT_DEFINED,
|
19
|
+
@details
|
20
|
+
),
|
21
|
+
Decouplio::Const::Validations::Doby::ALLOWED_OPTIONS_MESSAGE,
|
22
|
+
Decouplio::Const::Validations::Doby::MANUAL_URL
|
23
|
+
]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/decouplio/logic_dsl.rb
CHANGED
@@ -2,13 +2,15 @@
|
|
2
2
|
|
3
3
|
require_relative 'flow'
|
4
4
|
require_relative 'const/types'
|
5
|
+
require_relative 'const/doby_aide_options'
|
5
6
|
require_relative 'octo_hash_case'
|
6
7
|
require_relative 'errors/options_validation_error'
|
7
8
|
require_relative 'errors/palp_validation_error'
|
8
9
|
require_relative 'errors/resq_definition_error'
|
9
10
|
require_relative 'errors/wrap_block_is_not_defined_error'
|
10
11
|
require_relative 'errors/palp_block_is_not_defined_error'
|
11
|
-
require_relative 'errors/
|
12
|
+
require_relative 'errors/fail_can_not_be_first_step_error'
|
13
|
+
require_relative 'errors/aide_can_not_be_first_step_error'
|
12
14
|
require_relative 'errors/octo_block_is_not_defined_error'
|
13
15
|
|
14
16
|
module Decouplio
|
@@ -32,7 +34,7 @@ module Decouplio
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def fail(stp, **options)
|
35
|
-
raise Decouplio::Errors::
|
37
|
+
raise Decouplio::Errors::FailCanNotBeFirstStepError if @steps.empty?
|
36
38
|
|
37
39
|
@steps << options.merge(type: Decouplio::Const::Types::FAIL_TYPE, name: stp)
|
38
40
|
end
|
@@ -84,11 +86,36 @@ module Decouplio
|
|
84
86
|
end
|
85
87
|
|
86
88
|
def doby(doby_class, **options)
|
89
|
+
step_options = {}
|
90
|
+
options.each_key do |key|
|
91
|
+
step_options[key] = options.delete(key) if Decouplio::Const::DobyAideOptions::ALLOWED.include?(key)
|
92
|
+
end
|
93
|
+
doby_options = options
|
94
|
+
|
87
95
|
@steps << {
|
88
96
|
type: Decouplio::Const::Types::DOBY_TYPE,
|
89
97
|
name: doby_class.name.to_sym,
|
90
98
|
doby_class: doby_class,
|
91
|
-
doby_options:
|
99
|
+
doby_options: doby_options,
|
100
|
+
**step_options
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
def aide(aide_class, **options)
|
105
|
+
raise Decouplio::Errors::AideCanNotBeFirstStepError if @steps.empty?
|
106
|
+
|
107
|
+
step_options = {}
|
108
|
+
options.each_key do |key|
|
109
|
+
step_options[key] = options.delete(key) if Decouplio::Const::DobyAideOptions::ALLOWED.include?(key)
|
110
|
+
end
|
111
|
+
aide_options = options
|
112
|
+
|
113
|
+
@steps << {
|
114
|
+
type: Decouplio::Const::Types::AIDE_TYPE,
|
115
|
+
name: aide_class.name.to_sym,
|
116
|
+
aide_class: aide_class,
|
117
|
+
aide_options: aide_options,
|
118
|
+
**step_options
|
92
119
|
}
|
93
120
|
end
|
94
121
|
end
|
@@ -10,6 +10,8 @@ require_relative 'errors/extra_key_for_pass_error'
|
|
10
10
|
require_relative 'errors/extra_key_for_resq_error'
|
11
11
|
require_relative 'errors/extra_key_for_wrap_error'
|
12
12
|
require_relative 'errors/fail_finish_him_error'
|
13
|
+
require_relative 'errors/doby_finish_him_error'
|
14
|
+
require_relative 'errors/aide_finish_him_error'
|
13
15
|
require_relative 'errors/invalid_error_class_error'
|
14
16
|
require_relative 'errors/invalid_wrap_name_error'
|
15
17
|
require_relative 'errors/pass_finish_him_error'
|
@@ -20,9 +22,13 @@ require_relative 'errors/step_finish_him_error'
|
|
20
22
|
require_relative 'errors/step_is_not_defined_for_step_error'
|
21
23
|
require_relative 'errors/step_is_not_defined_for_fail_error'
|
22
24
|
require_relative 'errors/step_is_not_defined_for_wrap_error'
|
25
|
+
require_relative 'errors/step_is_not_defined_for_aide_error'
|
26
|
+
require_relative 'errors/step_is_not_defined_for_doby_error'
|
23
27
|
require_relative 'errors/wrap_finish_him_error'
|
24
28
|
require_relative 'errors/wrap_klass_method_error'
|
25
29
|
require_relative 'errors/step_controversial_keys_error'
|
30
|
+
require_relative 'errors/doby_controversial_keys_error'
|
31
|
+
require_relative 'errors/aide_controversial_keys_error'
|
26
32
|
require_relative 'errors/fail_controversial_keys_error'
|
27
33
|
require_relative 'errors/pass_controversial_keys_error'
|
28
34
|
require_relative 'errors/octo_controversial_keys_error'
|
@@ -86,6 +92,10 @@ module Decouplio
|
|
86
92
|
Decouplio::Const::Types::RESQ_TYPE_PASS
|
87
93
|
validate(options: options[:step_to_resq], step_names: step_names)
|
88
94
|
validate_resq(options: filtered_options)
|
95
|
+
when Decouplio::Const::Types::DOBY_TYPE
|
96
|
+
validate_doby(options: filtered_options, step_names: step_names)
|
97
|
+
when Decouplio::Const::Types::AIDE_TYPE
|
98
|
+
validate_aide(options: filtered_options, step_names: step_names)
|
89
99
|
end
|
90
100
|
end
|
91
101
|
|
@@ -142,6 +152,18 @@ module Decouplio
|
|
142
152
|
check_resq_exception_classes_inheritance(options: options)
|
143
153
|
end
|
144
154
|
|
155
|
+
def validate_doby(options:, step_names:)
|
156
|
+
check_step_presence_for_doby(options: options, step_names: step_names)
|
157
|
+
check_doby_controversial_keys(options: options)
|
158
|
+
check_doby_finish_him(options: options)
|
159
|
+
end
|
160
|
+
|
161
|
+
def validate_aide(options:, step_names:)
|
162
|
+
check_step_presence_for_aide(options: options, step_names: step_names)
|
163
|
+
check_aide_controversial_keys(options: options)
|
164
|
+
check_aide_finish_him(options: options)
|
165
|
+
end
|
166
|
+
|
145
167
|
def validate_name(name:)
|
146
168
|
return unless Decouplio::Const::ReservedMethods::NAMES.include?(name)
|
147
169
|
|
@@ -152,7 +174,7 @@ module Decouplio
|
|
152
174
|
|
153
175
|
def check_step_presence_for_step(options:, step_names:)
|
154
176
|
options.slice(*STEP_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
155
|
-
next if %i[on_success on_failure].include?(option_key) && option_value
|
177
|
+
next if %i[on_success on_failure].include?(option_key) && STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
|
156
178
|
|
157
179
|
next if step_names.keys.include?(option_value)
|
158
180
|
|
@@ -163,9 +185,35 @@ module Decouplio
|
|
163
185
|
end
|
164
186
|
end
|
165
187
|
|
188
|
+
def check_step_presence_for_doby(options:, step_names:)
|
189
|
+
options.slice(*STEP_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
190
|
+
next if %i[on_success on_failure].include?(option_key) && STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
|
191
|
+
|
192
|
+
next if step_names.keys.include?(option_value)
|
193
|
+
|
194
|
+
raise Decouplio::Errors::StepIsNotDefinedForDobyError.new(
|
195
|
+
errored_option: options.slice(option_key).to_s,
|
196
|
+
details: option_value
|
197
|
+
)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def check_step_presence_for_aide(options:, step_names:)
|
202
|
+
options.slice(*STEP_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
203
|
+
next if %i[on_success on_failure].include?(option_key) && STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
|
204
|
+
|
205
|
+
next if step_names.keys.include?(option_value)
|
206
|
+
|
207
|
+
raise Decouplio::Errors::StepIsNotDefinedForAideError.new(
|
208
|
+
errored_option: options.slice(option_key).to_s,
|
209
|
+
details: option_value
|
210
|
+
)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
166
214
|
def check_step_presence_for_fail(options:, step_names:)
|
167
215
|
options.slice(*STEP_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
168
|
-
next if %i[on_success on_failure].include?(option_key) && option_value
|
216
|
+
next if %i[on_success on_failure].include?(option_key) && STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
|
169
217
|
|
170
218
|
next if step_names.keys.include?(option_value)
|
171
219
|
|
@@ -178,7 +226,7 @@ module Decouplio
|
|
178
226
|
|
179
227
|
def check_step_presence_for_wrap(options:, step_names:)
|
180
228
|
options.slice(*WRAP_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
181
|
-
next if %i[on_success on_failure].include?(option_key) && option_value
|
229
|
+
next if %i[on_success on_failure].include?(option_key) && STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
|
182
230
|
|
183
231
|
next if step_names.keys.include?(option_value)
|
184
232
|
|
@@ -211,6 +259,30 @@ module Decouplio
|
|
211
259
|
end
|
212
260
|
end
|
213
261
|
|
262
|
+
def check_doby_controversial_keys(options:)
|
263
|
+
on_success_on_failure = options.slice(:on_success, :on_failure)
|
264
|
+
finish_him = options.slice(:finish_him)
|
265
|
+
|
266
|
+
if !on_success_on_failure.empty? && !finish_him.empty?
|
267
|
+
raise Decouplio::Errors::DobyControversialKeysError.new(
|
268
|
+
errored_option: on_success_on_failure.merge(finish_him).to_s,
|
269
|
+
details: [on_success_on_failure.keys.join(', '), :finish_him]
|
270
|
+
)
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
def check_aide_controversial_keys(options:)
|
275
|
+
on_success_on_failure = options.slice(:on_success, :on_failure)
|
276
|
+
finish_him = options.slice(:finish_him)
|
277
|
+
|
278
|
+
if !on_success_on_failure.empty? && !finish_him.empty?
|
279
|
+
raise Decouplio::Errors::AideControversialKeysError.new(
|
280
|
+
errored_option: on_success_on_failure.merge(finish_him).to_s,
|
281
|
+
details: [on_success_on_failure.keys.join(', '), :finish_him]
|
282
|
+
)
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
214
286
|
def validate_error_store(parent_action_class:, child_action_class:)
|
215
287
|
return if parent_action_class.error_store == child_action_class.error_store
|
216
288
|
|
@@ -304,11 +376,20 @@ module Decouplio
|
|
304
376
|
end
|
305
377
|
|
306
378
|
def check_octo_required_keys(options:)
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
379
|
+
if (OCTO_REQUIRED_KEYS - options.keys).size.zero?
|
380
|
+
if options.keys.sort == OCTO_REQUIRED_KEYS.sort
|
381
|
+
raise Decouplio::Errors::OctoControversialKeysError.new(
|
382
|
+
errored_option: options.slice(*OCTO_REQUIRED_KEYS),
|
383
|
+
details: OCTO_REQUIRED_KEYS
|
384
|
+
)
|
385
|
+
end
|
386
|
+
else
|
387
|
+
return if options.slice(*OCTO_REQUIRED_KEYS).size == 1
|
388
|
+
|
389
|
+
raise Decouplio::Errors::RequiredOptionsIsMissingForOctoError.new(
|
390
|
+
details: OCTO_REQUIRED_KEYS.join(', ')
|
391
|
+
)
|
392
|
+
end
|
312
393
|
end
|
313
394
|
|
314
395
|
def check_step_finish_him(options:)
|
@@ -324,6 +405,32 @@ module Decouplio
|
|
324
405
|
end
|
325
406
|
end
|
326
407
|
|
408
|
+
def check_doby_finish_him(options:)
|
409
|
+
finish_him_value = options.dig(:finish_him)
|
410
|
+
|
411
|
+
return unless finish_him_value && options.key?(:finish_him)
|
412
|
+
|
413
|
+
unless ALLOWED_STEP_FINISH_HIM_VALUES.include?(finish_him_value)
|
414
|
+
raise Decouplio::Errors::DobyFinishHimError.new(
|
415
|
+
errored_option: options.slice(:finish_him).to_s,
|
416
|
+
details: finish_him_value
|
417
|
+
)
|
418
|
+
end
|
419
|
+
end
|
420
|
+
|
421
|
+
def check_aide_finish_him(options:)
|
422
|
+
finish_him_value = options.dig(:finish_him)
|
423
|
+
|
424
|
+
return unless options.key?(:finish_him)
|
425
|
+
|
426
|
+
return if ALLOWED_FAIL_FINISH_HIM_VALUES.include?(finish_him_value)
|
427
|
+
|
428
|
+
raise Decouplio::Errors::AideFinishHimError.new(
|
429
|
+
errored_option: options.slice(:finish_him).to_s,
|
430
|
+
details: finish_him_value
|
431
|
+
)
|
432
|
+
end
|
433
|
+
|
327
434
|
def check_fail_finish_him(options:)
|
328
435
|
finish_him_value = options.dig(:finish_him)
|
329
436
|
|
@@ -455,6 +562,11 @@ module Decouplio
|
|
455
562
|
on_success
|
456
563
|
on_failure
|
457
564
|
].freeze
|
565
|
+
STEP_ALLOWED_ON_S_ON_F_VALUES = [
|
566
|
+
Decouplio::Const::Results::STEP_PASS,
|
567
|
+
Decouplio::Const::Results::STEP_FAIL,
|
568
|
+
Decouplio::Const::Results::FINISH_HIM
|
569
|
+
].freeze
|
458
570
|
STEP_ALLOWED_OPTIONS = %i[
|
459
571
|
on_success
|
460
572
|
on_failure
|
@@ -509,6 +621,7 @@ module Decouplio
|
|
509
621
|
|
510
622
|
OCTO_ALLOWED_OPTIONS = %i[
|
511
623
|
ctx_key
|
624
|
+
method
|
512
625
|
if
|
513
626
|
unless
|
514
627
|
].freeze
|
@@ -518,6 +631,7 @@ module Decouplio
|
|
518
631
|
].freeze
|
519
632
|
OCTO_REQUIRED_KEYS = %i[
|
520
633
|
ctx_key
|
634
|
+
method
|
521
635
|
].freeze
|
522
636
|
|
523
637
|
# *************************************************
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base_step'
|
4
|
+
|
5
|
+
module Decouplio
|
6
|
+
module Steps
|
7
|
+
class Aide < Decouplio::Steps::BaseStep
|
8
|
+
def initialize(name:, aide_class:, aide_options:, on_success_type:, on_failure_type:)
|
9
|
+
super()
|
10
|
+
@name = name
|
11
|
+
@aide_class = aide_class
|
12
|
+
@aide_options = aide_options
|
13
|
+
@on_success_type = on_success_type
|
14
|
+
@on_failure_type = on_failure_type
|
15
|
+
end
|
16
|
+
|
17
|
+
def process(instance:)
|
18
|
+
instance.append_railway_flow(@name)
|
19
|
+
result = @aide_class.call(
|
20
|
+
ctx: instance.ctx,
|
21
|
+
error_store: instance.error_store,
|
22
|
+
**@aide_options
|
23
|
+
)
|
24
|
+
resolve(instance: instance, result: result)
|
25
|
+
end
|
26
|
+
|
27
|
+
def resolve(instance:, result:)
|
28
|
+
Decouplio::Steps::Shared::FailResolver.call(
|
29
|
+
instance: instance,
|
30
|
+
result: result,
|
31
|
+
on_success_type: @on_success_type,
|
32
|
+
on_failure_type: @on_failure_type
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/decouplio/steps/doby.rb
CHANGED
@@ -5,27 +5,32 @@ require_relative 'base_step'
|
|
5
5
|
module Decouplio
|
6
6
|
module Steps
|
7
7
|
class Doby < Decouplio::Steps::BaseStep
|
8
|
-
def initialize(name:, doby_class:, doby_options:)
|
8
|
+
def initialize(name:, doby_class:, doby_options:, on_success_type:, on_failure_type:)
|
9
9
|
super()
|
10
10
|
@name = name
|
11
11
|
@doby_class = doby_class
|
12
12
|
@doby_options = doby_options
|
13
|
+
@on_success_type = on_success_type
|
14
|
+
@on_failure_type = on_failure_type
|
13
15
|
end
|
14
16
|
|
15
17
|
def process(instance:)
|
16
18
|
instance.append_railway_flow(@name)
|
17
|
-
result = @doby_class.call(
|
19
|
+
result = @doby_class.call(
|
20
|
+
ctx: instance.ctx,
|
21
|
+
error_store: instance.error_store,
|
22
|
+
**@doby_options
|
23
|
+
)
|
18
24
|
resolve(result: result, instance: instance)
|
19
25
|
end
|
20
26
|
|
21
27
|
def resolve(result:, instance:)
|
22
|
-
|
23
|
-
instance
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
28
|
+
Decouplio::Steps::Shared::StepResolver.call(
|
29
|
+
instance: instance,
|
30
|
+
result: result,
|
31
|
+
on_success_type: @on_success_type,
|
32
|
+
on_failure_type: @on_failure_type
|
33
|
+
)
|
29
34
|
end
|
30
35
|
end
|
31
36
|
end
|
data/lib/decouplio/steps/fail.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'base_step'
|
4
|
+
require_relative 'shared/fail_resolver'
|
4
5
|
|
5
6
|
module Decouplio
|
6
7
|
module Steps
|
@@ -22,28 +23,12 @@ module Decouplio
|
|
22
23
|
private
|
23
24
|
|
24
25
|
def resolve(result:, instance:)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
instance.fail_action
|
32
|
-
Decouplio::Const::Results::PASS
|
33
|
-
when Decouplio::Const::Results::FINISH_HIM
|
34
|
-
instance.fail_action
|
35
|
-
Decouplio::Const::Results::FINISH_HIM
|
36
|
-
end
|
37
|
-
elsif @on_failure_type == Decouplio::Const::Results::PASS
|
38
|
-
instance.pass_action
|
39
|
-
Decouplio::Const::Results::FAIL
|
40
|
-
elsif @on_failure_type == Decouplio::Const::Results::FAIL
|
41
|
-
instance.fail_action
|
42
|
-
Decouplio::Const::Results::FAIL
|
43
|
-
elsif @on_failure_type == Decouplio::Const::Results::FINISH_HIM
|
44
|
-
instance.fail_action
|
45
|
-
Decouplio::Const::Results::FINISH_HIM
|
46
|
-
end
|
26
|
+
Decouplio::Steps::Shared::FailResolver.call(
|
27
|
+
instance: instance,
|
28
|
+
result: result,
|
29
|
+
on_success_type: @on_success_type,
|
30
|
+
on_failure_type: @on_failure_type
|
31
|
+
)
|
47
32
|
end
|
48
33
|
end
|
49
34
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'base_step'
|
4
|
+
require_relative 'shared/fail_resolver'
|
4
5
|
|
5
6
|
module Decouplio
|
6
7
|
module Steps
|
@@ -27,28 +28,12 @@ module Decouplio
|
|
27
28
|
|
28
29
|
instance.error_store.merge(outcome.error_store)
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
instance.fail_action
|
37
|
-
Decouplio::Const::Results::PASS
|
38
|
-
when Decouplio::Const::Results::FINISH_HIM
|
39
|
-
instance.fail_action
|
40
|
-
Decouplio::Const::Results::FINISH_HIM
|
41
|
-
end
|
42
|
-
elsif @on_failure_type == Decouplio::Const::Results::PASS
|
43
|
-
instance.pass_action
|
44
|
-
Decouplio::Const::Results::FAIL
|
45
|
-
elsif @on_failure_type == Decouplio::Const::Results::FAIL
|
46
|
-
instance.fail_action
|
47
|
-
Decouplio::Const::Results::FAIL
|
48
|
-
elsif @on_failure_type == Decouplio::Const::Results::FINISH_HIM
|
49
|
-
instance.fail_action
|
50
|
-
Decouplio::Const::Results::FINISH_HIM
|
51
|
-
end
|
31
|
+
Decouplio::Steps::Shared::FailResolver.call(
|
32
|
+
instance: instance,
|
33
|
+
result: result,
|
34
|
+
on_success_type: @on_success_type,
|
35
|
+
on_failure_type: @on_failure_type
|
36
|
+
)
|
52
37
|
end
|
53
38
|
end
|
54
39
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'base_step'
|
4
|
+
require_relative 'shared/step_resolver'
|
4
5
|
|
5
6
|
module Decouplio
|
6
7
|
module Steps
|
@@ -27,24 +28,12 @@ module Decouplio
|
|
27
28
|
|
28
29
|
instance.error_store.merge(outcome.error_store)
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
Decouplio::Const::Results::FINISH_HIM
|
37
|
-
end
|
38
|
-
elsif @on_failure_type == Decouplio::Const::Results::PASS
|
39
|
-
instance.pass_action
|
40
|
-
Decouplio::Const::Results::FAIL
|
41
|
-
elsif @on_failure_type == Decouplio::Const::Results::FAIL
|
42
|
-
instance.fail_action
|
43
|
-
Decouplio::Const::Results::FAIL
|
44
|
-
elsif @on_failure_type == Decouplio::Const::Results::FINISH_HIM
|
45
|
-
instance.fail_action
|
46
|
-
Decouplio::Const::Results::FINISH_HIM
|
47
|
-
end
|
31
|
+
Decouplio::Steps::Shared::StepResolver.call(
|
32
|
+
instance: instance,
|
33
|
+
result: result,
|
34
|
+
on_success_type: @on_success_type,
|
35
|
+
on_failure_type: @on_failure_type
|
36
|
+
)
|
48
37
|
end
|
49
38
|
end
|
50
39
|
end
|
data/lib/decouplio/steps/octo.rb
CHANGED
@@ -7,15 +7,20 @@ module Decouplio
|
|
7
7
|
class Octo < BaseStep
|
8
8
|
attr_accessor :hash_case
|
9
9
|
|
10
|
-
def initialize(name:, ctx_key:)
|
10
|
+
def initialize(name:, ctx_key:, method:)
|
11
11
|
super()
|
12
12
|
@name = name
|
13
13
|
@ctx_key = ctx_key
|
14
|
+
@method = method
|
14
15
|
end
|
15
16
|
|
16
17
|
def process(instance:)
|
17
18
|
instance.append_railway_flow(@name)
|
18
|
-
|
19
|
+
if @method
|
20
|
+
instance.send(@method, **instance.ctx)
|
21
|
+
else
|
22
|
+
instance[@ctx_key]
|
23
|
+
end
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'base_step'
|
4
|
+
require_relative 'shared/fail_resolver'
|
4
5
|
|
5
6
|
module Decouplio
|
6
7
|
module Steps
|
@@ -15,7 +16,10 @@ module Decouplio
|
|
15
16
|
|
16
17
|
def process(instance:)
|
17
18
|
instance.append_railway_flow(@name)
|
18
|
-
result = @service.call(
|
19
|
+
result = @service.call(
|
20
|
+
ctx: instance.ctx,
|
21
|
+
error_store: instance.error_store
|
22
|
+
)
|
19
23
|
|
20
24
|
resolve(result: result, instance: instance)
|
21
25
|
end
|
@@ -23,28 +27,12 @@ module Decouplio
|
|
23
27
|
private
|
24
28
|
|
25
29
|
def resolve(result:, instance:)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
instance.fail_action
|
33
|
-
Decouplio::Const::Results::PASS
|
34
|
-
when Decouplio::Const::Results::FINISH_HIM
|
35
|
-
instance.fail_action
|
36
|
-
Decouplio::Const::Results::FINISH_HIM
|
37
|
-
end
|
38
|
-
elsif @on_failure_type == Decouplio::Const::Results::PASS
|
39
|
-
instance.pass_action
|
40
|
-
Decouplio::Const::Results::FAIL
|
41
|
-
elsif @on_failure_type == Decouplio::Const::Results::FAIL
|
42
|
-
instance.fail_action
|
43
|
-
Decouplio::Const::Results::FAIL
|
44
|
-
elsif @on_failure_type == Decouplio::Const::Results::FINISH_HIM
|
45
|
-
instance.fail_action
|
46
|
-
Decouplio::Const::Results::FINISH_HIM
|
47
|
-
end
|
30
|
+
Decouplio::Steps::Shared::FailResolver.call(
|
31
|
+
instance: instance,
|
32
|
+
result: result,
|
33
|
+
on_success_type: @on_success_type,
|
34
|
+
on_failure_type: @on_failure_type
|
35
|
+
)
|
48
36
|
end
|
49
37
|
end
|
50
38
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'base_step'
|
4
|
+
require_relative 'shared/step_resolver'
|
4
5
|
|
5
6
|
module Decouplio
|
6
7
|
module Steps
|
@@ -15,7 +16,10 @@ module Decouplio
|
|
15
16
|
|
16
17
|
def process(instance:)
|
17
18
|
instance.append_railway_flow(@name)
|
18
|
-
result = @service.call(
|
19
|
+
result = @service.call(
|
20
|
+
ctx: instance.ctx,
|
21
|
+
error_store: instance.error_store
|
22
|
+
)
|
19
23
|
|
20
24
|
resolve(result: result, instance: instance)
|
21
25
|
end
|
@@ -23,24 +27,12 @@ module Decouplio
|
|
23
27
|
private
|
24
28
|
|
25
29
|
def resolve(result:, instance:)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
Decouplio::Const::Results::FINISH_HIM
|
33
|
-
end
|
34
|
-
elsif @on_failure_type == Decouplio::Const::Results::PASS
|
35
|
-
instance.pass_action
|
36
|
-
Decouplio::Const::Results::FAIL
|
37
|
-
elsif @on_failure_type == Decouplio::Const::Results::FAIL
|
38
|
-
instance.fail_action
|
39
|
-
Decouplio::Const::Results::FAIL
|
40
|
-
elsif @on_failure_type == Decouplio::Const::Results::FINISH_HIM
|
41
|
-
instance.fail_action
|
42
|
-
Decouplio::Const::Results::FINISH_HIM
|
43
|
-
end
|
30
|
+
Decouplio::Steps::Shared::StepResolver.call(
|
31
|
+
instance: instance,
|
32
|
+
result: result,
|
33
|
+
on_success_type: @on_success_type,
|
34
|
+
on_failure_type: @on_failure_type
|
35
|
+
)
|
44
36
|
end
|
45
37
|
end
|
46
38
|
end
|