decouplio 1.0.0alpha1 → 1.0.0alpha2

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/README.md +26 -2
  4. data/benchmarks/Gemfile +2 -1
  5. data/benchmarks/multi_step_benchmark.rb +335 -0
  6. data/benchmarks/single_step_benchmark.rb +159 -0
  7. data/docker-compose.yml +13 -2
  8. data/docs/deny.rb +59 -0
  9. data/docs/doby.rb +1 -1
  10. data/docs/doby_deny.md +171 -0
  11. data/docs/fail.md +143 -0
  12. data/docs/fail.rb +126 -29
  13. data/docs/resq.md +2 -2
  14. data/docs/step.md +148 -0
  15. data/docs/step.rb +119 -18
  16. data/docs/step_as_a_service.md +25 -11
  17. data/docs/step_as_a_service.rb +2 -2
  18. data/docs/wrap.md +8 -0
  19. data/lib/decouplio/action.rb +22 -3
  20. data/lib/decouplio/composer.rb +78 -12
  21. data/lib/decouplio/const/reserved_methods.rb +13 -9
  22. data/lib/decouplio/const/results.rb +2 -0
  23. data/lib/decouplio/const/types.rb +11 -5
  24. data/lib/decouplio/const/validations/deny.rb +11 -0
  25. data/lib/decouplio/const/validations/fail.rb +1 -1
  26. data/lib/decouplio/errors/deny_can_not_be_first_step_error.rb +18 -0
  27. data/lib/decouplio/errors/{fail_is_first_step_error.rb → fail_can_not_be_first_step_error.rb} +1 -1
  28. data/lib/decouplio/logic_dsl.rb +14 -2
  29. data/lib/decouplio/options_validator.rb +8 -3
  30. data/lib/decouplio/steps/deny.rb +31 -0
  31. data/lib/decouplio/steps/doby.rb +5 -1
  32. data/lib/decouplio/steps/fail.rb +7 -22
  33. data/lib/decouplio/steps/inner_action_fail.rb +7 -22
  34. data/lib/decouplio/steps/inner_action_step.rb +7 -18
  35. data/lib/decouplio/steps/service_fail.rb +11 -23
  36. data/lib/decouplio/steps/service_pass.rb +4 -1
  37. data/lib/decouplio/steps/service_step.rb +11 -19
  38. data/lib/decouplio/steps/shared/fail_resolver.rb +40 -0
  39. data/lib/decouplio/steps/shared/step_resolver.rb +43 -0
  40. data/lib/decouplio/steps/step.rb +7 -18
  41. data/lib/decouplio/steps/wrap.rb +7 -18
  42. data/lib/decouplio/version.rb +1 -1
  43. metadata +12 -5
  44. data/benchmarks/benchmarks.rb +0 -527
  45. data/docs/doby.md +0 -80
@@ -21,6 +21,7 @@ require_relative 'steps/service_step'
21
21
  require_relative 'steps/service_fail'
22
22
  require_relative 'steps/service_pass'
23
23
  require_relative 'steps/doby'
24
+ require_relative 'steps/deny'
24
25
  require_relative 'options_validator'
25
26
  require_relative 'validators/condition'
26
27
 
@@ -130,6 +131,8 @@ module Decouplio
130
131
  create_inner_service_pass(stp, flow)
131
132
  when Decouplio::Const::Types::DOBY_TYPE
132
133
  create_doby(stp)
134
+ when Decouplio::Const::Types::DENY_TYPE
135
+ create_deny(stp)
133
136
  end
134
137
  end
135
138
 
@@ -274,6 +277,14 @@ module Decouplio
274
277
  )
275
278
  end
276
279
 
280
+ def create_deny(stp)
281
+ Decouplio::Steps::Deny.new(
282
+ name: stp[:name],
283
+ deny_class: stp[:deny_class],
284
+ deny_options: stp[:deny_options]
285
+ )
286
+ end
287
+
277
288
  def compose_flow(flow, palps, next_steps, action_class, flow_hash = {})
278
289
  flow.each_with_index do |(step_id, stp), idx|
279
290
  case stp[:type]
@@ -294,6 +305,8 @@ module Decouplio
294
305
  compose_fail_flow(stp, step_id, flow, idx, flow_hash, next_steps)
295
306
  when Decouplio::Const::Types::DOBY_TYPE
296
307
  compose_doby_flow(stp, step_id, flow, idx, flow_hash, next_steps)
308
+ when Decouplio::Const::Types::DENY_TYPE
309
+ compose_deny_flow(stp, step_id, flow, idx, flow_hash, next_steps)
297
310
  when Decouplio::Const::Types::IF_TYPE_PASS, Decouplio::Const::Types::UNLESS_TYPE_PASS
298
311
  compose_pass_condition_flow(stp, flow, idx, flow_hash)
299
312
  when Decouplio::Const::Types::IF_TYPE_FAIL, Decouplio::Const::Types::UNLESS_TYPE_FAIL
@@ -350,6 +363,29 @@ module Decouplio
350
363
  stp[:flow][Decouplio::Const::Results::FINISH_HIM] = Decouplio::Const::Results::NO_STEP
351
364
  end
352
365
 
366
+ def compose_deny_flow(stp, _step_id, flow, idx, flow_hash, next_steps)
367
+ flow_values = flow.values + (next_steps&.values || [])
368
+ stp[:flow][Decouplio::Const::Results::PASS] = next_failure_step(
369
+ flow_values,
370
+ idx,
371
+ nil
372
+ )
373
+ stp[:flow][Decouplio::Const::Results::FAIL] = next_failure_step(
374
+ flow_values,
375
+ idx,
376
+ nil
377
+ )
378
+ stp[:flow][Decouplio::Const::Results::ERROR] = next_failure_step(
379
+ flow_values,
380
+ idx,
381
+ nil
382
+ )
383
+ stp[:flow][Decouplio::Const::Results::PASS] ||= flow_hash[Decouplio::Const::Results::FAIL]
384
+ stp[:flow][Decouplio::Const::Results::FAIL] ||= flow_hash[Decouplio::Const::Results::FAIL]
385
+ stp[:flow][Decouplio::Const::Results::ERROR] ||= flow_hash[Decouplio::Const::Results::ERROR]
386
+ stp[:flow][Decouplio::Const::Results::FINISH_HIM] = Decouplio::Const::Results::NO_STEP
387
+ end
388
+
353
389
  def compose_fail_flow(stp, step_id, flow, idx, flow_hash, next_steps)
354
390
  flow_values = flow.values + (next_steps&.values || [])
355
391
  stp[:flow][Decouplio::Const::Results::PASS] = next_failure_step(
@@ -409,18 +445,30 @@ module Decouplio
409
445
  return :finish_him if [:on_success, true].include?(finish_him(stp))
410
446
 
411
447
  step_id = stp.dig(:flow, Decouplio::Const::Results::PASS)
412
- Decouplio::Const::Types::PASS_FLOW.include?(
413
- flow[step_id]&.[](:type)
414
- )
448
+ if step_id.nil? && Decouplio::Const::Results::STEP_PASS == stp[:on_success]
449
+ Decouplio::Const::Results::STEP_PASS
450
+ elsif step_id.nil? && Decouplio::Const::Results::STEP_FAIL == stp[:on_success]
451
+ Decouplio::Const::Results::STEP_FAIL
452
+ else
453
+ Decouplio::Const::Types::PASS_FLOW.include?(
454
+ flow[step_id]&.[](:type)
455
+ )
456
+ end
415
457
  end
416
458
 
417
459
  def failure_type(flow, stp)
418
460
  return :finish_him if [:on_failure, true].include?(finish_him(stp))
419
461
 
420
462
  step_id = stp.dig(:flow, Decouplio::Const::Results::FAIL)
421
- Decouplio::Const::Types::FAIL_FLOW.include?(
422
- flow[step_id]&.[](:type)
423
- )
463
+ if step_id.nil? && Decouplio::Const::Results::STEP_PASS == stp[:on_failure]
464
+ Decouplio::Const::Results::STEP_PASS
465
+ elsif step_id.nil? && Decouplio::Const::Results::STEP_FAIL == stp[:on_on_failure]
466
+ Decouplio::Const::Results::STEP_FAIL
467
+ else
468
+ Decouplio::Const::Types::FAIL_FLOW.include?(
469
+ flow[step_id]&.[](:type)
470
+ )
471
+ end
424
472
  end
425
473
 
426
474
  def finish_him(stp)
@@ -543,7 +591,18 @@ module Decouplio
543
591
  def next_success_step(steps, idx, value)
544
592
  steps_slice = steps[(idx + 1)..]
545
593
  steps_slice.each_with_index do |stp, index|
546
- if value == stp[:name]
594
+ if (
595
+ Decouplio::Const::Results::STEP_PASS == value &&
596
+ Decouplio::Const::Types::SUCCESS_TRACK_STEP_TYPES.include?(stp[:type])
597
+ ) || (
598
+ Decouplio::Const::Results::STEP_FAIL == value &&
599
+ Decouplio::Const::Types::FAILURE_TRACK_STEP_TYPES.include?(stp[:type])
600
+ ) || (
601
+ !value &&
602
+ Decouplio::Const::Types::SUCCESS_TRACK_STEP_TYPES.include?(stp[:type])
603
+ )
604
+ return stp[:step_id]
605
+ elsif value == stp[:name]
547
606
  prev_step = steps_slice[index - 1]
548
607
  if [
549
608
  Decouplio::Const::Types::IF_TYPE_PASS,
@@ -553,8 +612,6 @@ module Decouplio
553
612
  else
554
613
  return stp[:step_id]
555
614
  end
556
- elsif !value && Decouplio::Const::Types::SUCCESS_TRACK_STEP_TYPES.include?(stp[:type])
557
- return stp[:step_id]
558
615
  end
559
616
  end
560
617
 
@@ -564,7 +621,18 @@ module Decouplio
564
621
  def next_failure_step(steps, idx, value)
565
622
  steps_slice = steps[(idx + 1)..]
566
623
  steps_slice.each_with_index do |stp, index|
567
- if value == stp[:name]
624
+ if (
625
+ Decouplio::Const::Results::STEP_PASS == value &&
626
+ Decouplio::Const::Types::SUCCESS_TRACK_STEP_TYPES.include?(stp[:type])
627
+ ) || (
628
+ Decouplio::Const::Results::STEP_FAIL == value &&
629
+ Decouplio::Const::Types::FAILURE_TRACK_STEP_TYPES.include?(stp[:type])
630
+ ) || (
631
+ !value &&
632
+ Decouplio::Const::Types::FAILURE_TRACK_STEP_TYPES.include?(stp[:type])
633
+ )
634
+ return stp[:step_id]
635
+ elsif value == stp[:name]
568
636
  prev_step = steps_slice[index - 1]
569
637
  if [
570
638
  Decouplio::Const::Types::IF_TYPE_FAIL,
@@ -574,8 +642,6 @@ module Decouplio
574
642
  else
575
643
  return stp[:step_id]
576
644
  end
577
- elsif !value && Decouplio::Const::Types::FAILURE_TRACK_STEP_TYPES.include?(stp[:type])
578
- return stp[:step_id]
579
645
  end
580
646
  end
581
647
 
@@ -1,17 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'results'
4
+
3
5
  module Decouplio
4
6
  module Const
5
7
  module ReservedMethods
6
- NAMES = %i[
7
- []
8
- success?
9
- failure?
10
- fail_action
11
- pass_action
12
- append_railway_flow
13
- inspect
14
- to_s
8
+ NAMES = [
9
+ :[],
10
+ :success?,
11
+ :failure?,
12
+ :fail_action,
13
+ :pass_action,
14
+ :append_railway_flow,
15
+ :inspect,
16
+ :to_s,
17
+ Decouplio::Const::Results::STEP_PASS,
18
+ Decouplio::Const::Results::STEP_FAIL
15
19
  ].freeze
16
20
  end
17
21
  end
@@ -8,6 +8,8 @@ module Decouplio
8
8
  ERROR = :error
9
9
  FINISH_HIM = :finish_him
10
10
  NO_STEP = nil
11
+ STEP_PASS = :PASS
12
+ STEP_FAIL = :FAIL
11
13
  end
12
14
  end
13
15
  end
@@ -14,6 +14,7 @@ module Decouplio
14
14
  UNLESS_TYPE_FAIL = :unless_fail
15
15
  OCTO_TYPE = :octo
16
16
  DOBY_TYPE = :doby
17
+ DENY_TYPE = :deny
17
18
  ACTION_TYPE_STEP = :action_step
18
19
  ACTION_TYPE_FAIL = :action_fail
19
20
  ACTION_TYPE_PASS = :action_pass
@@ -93,7 +94,8 @@ module Decouplio
93
94
  UNLESS_TYPE_PASS => RESQ_TYPE_STEP,
94
95
  IF_TYPE_FAIL => RESQ_TYPE_FAIL,
95
96
  UNLESS_TYPE_FAIL => RESQ_TYPE_FAIL,
96
- DOBY_TYPE => RESQ_TYPE_STEP
97
+ DOBY_TYPE => RESQ_TYPE_STEP,
98
+ DENY_TYPE => RESQ_TYPE_FAIL
97
99
  }.freeze
98
100
  STEP_TYPE_TO_INNER_TYPE = {
99
101
  STEP_TYPE => ACTION_TYPE_STEP,
@@ -115,7 +117,8 @@ module Decouplio
115
117
  OCTO_TYPE,
116
118
  WRAP_TYPE,
117
119
  RESQ_TYPE,
118
- DOBY_TYPE
120
+ DOBY_TYPE,
121
+ DENY_TYPE
119
122
  ].freeze
120
123
  PASS_FLOW = [
121
124
  STEP_TYPE,
@@ -135,7 +138,8 @@ module Decouplio
135
138
  IF_TYPE_FAIL,
136
139
  UNLESS_TYPE_FAIL,
137
140
  ACTION_TYPE_FAIL,
138
- SERVICE_TYPE_FAIL
141
+ SERVICE_TYPE_FAIL,
142
+ DENY_TYPE
139
143
  ].freeze
140
144
 
141
145
  MAIN_FLOW_TYPES = [
@@ -143,7 +147,8 @@ module Decouplio
143
147
  FAIL_TYPE,
144
148
  PASS_TYPE,
145
149
  WRAP_TYPE,
146
- DOBY_TYPE
150
+ DOBY_TYPE,
151
+ DENY_TYPE
147
152
  ].freeze
148
153
  SUCCESS_TRACK_STEP_TYPES = [
149
154
  STEP_TYPE,
@@ -166,7 +171,8 @@ module Decouplio
166
171
  UNLESS_TYPE_FAIL,
167
172
  RESQ_TYPE_FAIL,
168
173
  ACTION_TYPE_FAIL,
169
- SERVICE_TYPE_FAIL
174
+ SERVICE_TYPE_FAIL,
175
+ DENY_TYPE
170
176
  ].freeze
171
177
  end
172
178
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decouplio
4
+ module Const
5
+ module Validations
6
+ module Deny
7
+ FIRST_STEP = '"deny" can not be the first step'
8
+ end
9
+ end
10
+ end
11
+ end
@@ -27,7 +27,7 @@ module Decouplio
27
27
  OPTIONS_IS_NOT_ALLOWED = '"%s" option(s) is not allowed for "fail"'
28
28
  METHOD_NOT_DEFINED = 'fail :%s'
29
29
  CONTROVERSIAL_KEYS = '"%s" option(s) is not allowed along with "%s" option(s)'
30
- FIRST_STEP = '"fail" can not be first step'
30
+ FIRST_STEP = '"fail" can not be the first step'
31
31
  end
32
32
  end
33
33
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base_error'
4
+ require_relative '../const/validations/deny'
5
+
6
+ module Decouplio
7
+ module Errors
8
+ class DenyCanNotBeFirstStepError < Decouplio::Errors::BaseError
9
+ def template
10
+ Decouplio::Const::Validations::Deny::FIRST_STEP
11
+ end
12
+
13
+ def interpolation_values
14
+ []
15
+ end
16
+ end
17
+ end
18
+ end
@@ -5,7 +5,7 @@ require_relative '../const/validations/fail'
5
5
 
6
6
  module Decouplio
7
7
  module Errors
8
- class FailCanNotBeTheFirstStepError < Decouplio::Errors::BaseError
8
+ class FailCanNotBeFirstStepError < Decouplio::Errors::BaseError
9
9
  def template
10
10
  Decouplio::Const::Validations::Fail::FIRST_STEP
11
11
  end
@@ -8,7 +8,8 @@ require_relative 'errors/palp_validation_error'
8
8
  require_relative 'errors/resq_definition_error'
9
9
  require_relative 'errors/wrap_block_is_not_defined_error'
10
10
  require_relative 'errors/palp_block_is_not_defined_error'
11
- require_relative 'errors/fail_is_first_step_error'
11
+ require_relative 'errors/fail_can_not_be_first_step_error'
12
+ require_relative 'errors/deny_can_not_be_first_step_error'
12
13
  require_relative 'errors/octo_block_is_not_defined_error'
13
14
 
14
15
  module Decouplio
@@ -32,7 +33,7 @@ module Decouplio
32
33
  end
33
34
 
34
35
  def fail(stp, **options)
35
- raise Decouplio::Errors::FailCanNotBeTheFirstStepError if @steps.empty?
36
+ raise Decouplio::Errors::FailCanNotBeFirstStepError if @steps.empty?
36
37
 
37
38
  @steps << options.merge(type: Decouplio::Const::Types::FAIL_TYPE, name: stp)
38
39
  end
@@ -91,6 +92,17 @@ module Decouplio
91
92
  doby_options: options
92
93
  }
93
94
  end
95
+
96
+ def deny(deny_class, **options)
97
+ raise Decouplio::Errors::DenyCanNotBeFirstStepError if @steps.empty?
98
+
99
+ @steps << {
100
+ type: Decouplio::Const::Types::DENY_TYPE,
101
+ name: deny_class.name.to_sym,
102
+ deny_class: deny_class,
103
+ deny_options: options
104
+ }
105
+ end
94
106
  end
95
107
  end
96
108
  end
@@ -152,7 +152,7 @@ module Decouplio
152
152
 
153
153
  def check_step_presence_for_step(options:, step_names:)
154
154
  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 == :finish_him
155
+ next if %i[on_success on_failure].include?(option_key) && STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
156
156
 
157
157
  next if step_names.keys.include?(option_value)
158
158
 
@@ -165,7 +165,7 @@ module Decouplio
165
165
 
166
166
  def check_step_presence_for_fail(options:, step_names:)
167
167
  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 == :finish_him
168
+ next if %i[on_success on_failure].include?(option_key) && STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
169
169
 
170
170
  next if step_names.keys.include?(option_value)
171
171
 
@@ -178,7 +178,7 @@ module Decouplio
178
178
 
179
179
  def check_step_presence_for_wrap(options:, step_names:)
180
180
  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 == :finish_him
181
+ next if %i[on_success on_failure].include?(option_key) && STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
182
182
 
183
183
  next if step_names.keys.include?(option_value)
184
184
 
@@ -455,6 +455,11 @@ module Decouplio
455
455
  on_success
456
456
  on_failure
457
457
  ].freeze
458
+ STEP_ALLOWED_ON_S_ON_F_VALUES = [
459
+ Decouplio::Const::Results::STEP_PASS,
460
+ Decouplio::Const::Results::STEP_FAIL,
461
+ Decouplio::Const::Results::FINISH_HIM
462
+ ].freeze
458
463
  STEP_ALLOWED_OPTIONS = %i[
459
464
  on_success
460
465
  on_failure
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base_step'
4
+
5
+ module Decouplio
6
+ module Steps
7
+ class Deny < Decouplio::Steps::BaseStep
8
+ def initialize(name:, deny_class:, deny_options:)
9
+ super()
10
+ @name = name
11
+ @deny_class = deny_class
12
+ @deny_options = deny_options
13
+ end
14
+
15
+ def process(instance:)
16
+ instance.append_railway_flow(@name)
17
+ @deny_class.call(
18
+ ctx: instance.ctx,
19
+ error_store: instance.error_store,
20
+ **@deny_options
21
+ )
22
+ resolve(instance: instance)
23
+ end
24
+
25
+ def resolve(instance:)
26
+ instance.fail_action
27
+ Decouplio::Const::Results::FAIL
28
+ end
29
+ end
30
+ end
31
+ end
@@ -14,7 +14,11 @@ module Decouplio
14
14
 
15
15
  def process(instance:)
16
16
  instance.append_railway_flow(@name)
17
- result = @doby_class.call(ctx: instance.ctx, **@doby_options)
17
+ result = @doby_class.call(
18
+ ctx: instance.ctx,
19
+ error_store: instance.error_store,
20
+ **@doby_options
21
+ )
18
22
  resolve(result: result, instance: instance)
19
23
  end
20
24
 
@@ -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
- if result
26
- case @on_success_type
27
- when Decouplio::Const::Results::PASS
28
- instance.pass_action
29
- Decouplio::Const::Results::PASS
30
- when Decouplio::Const::Results::FAIL
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
- if result
31
- case @on_success_type
32
- when Decouplio::Const::Results::PASS
33
- instance.pass_action
34
- Decouplio::Const::Results::PASS
35
- when Decouplio::Const::Results::FAIL
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
- if result
31
- if [Decouplio::Const::Results::PASS, Decouplio::Const::Results::FAIL].include?(@on_success_type)
32
- instance.pass_action
33
- Decouplio::Const::Results::PASS
34
- elsif @on_success_type == Decouplio::Const::Results::FINISH_HIM
35
- instance.pass_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
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
@@ -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(ctx: instance.ctx)
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
- if result
27
- case @on_success_type
28
- when Decouplio::Const::Results::PASS
29
- instance.pass_action
30
- Decouplio::Const::Results::PASS
31
- when Decouplio::Const::Results::FAIL
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
@@ -15,7 +15,10 @@ module Decouplio
15
15
 
16
16
  def process(instance:)
17
17
  instance.append_railway_flow(@name)
18
- @service.call(ctx: instance.ctx)
18
+ @service.call(
19
+ ctx: instance.ctx,
20
+ error_store: instance.error_store
21
+ )
19
22
 
20
23
  resolve(instance: instance)
21
24
  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(ctx: instance.ctx)
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
- if result
27
- if [Decouplio::Const::Results::PASS, Decouplio::Const::Results::FAIL].include?(@on_success_type)
28
- instance.pass_action
29
- Decouplio::Const::Results::PASS
30
- elsif @on_success_type == Decouplio::Const::Results::FINISH_HIM
31
- instance.pass_action
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