Class: Decouplio::Steps::Shared::StepResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/decouplio/steps/shared/step_resolver.rb

Class Method Summary collapse

Class Method Details

.call(instance:, result:, on_success_type:, on_failure_type:) ⇒ Object



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
39
# File 'lib/decouplio/steps/shared/step_resolver.rb', line 7

def self.call(instance:, result:, on_success_type:, on_failure_type:)
  if result
    if [
      Decouplio::Const::Results::PASS,
      Decouplio::Const::Results::FAIL,
      Decouplio::Const::Results::STEP_PASS
    ].include?(on_success_type)
      instance.pass_action
      Decouplio::Const::Results::PASS
    elsif Decouplio::Const::Results::STEP_FAIL == on_success_type
      instance.fail_action
      Decouplio::Const::Results::PASS
    elsif on_success_type == Decouplio::Const::Results::FINISH_HIM
      instance.pass_action
      Decouplio::Const::Results::FINISH_HIM
    end
  elsif Decouplio::Const::Results::STEP_PASS == on_failure_type
    instance.pass_action
    Decouplio::Const::Results::PASS
  elsif Decouplio::Const::Results::STEP_FAIL == on_failure_type
    instance.fail_action
    Decouplio::Const::Results::PASS
  elsif on_failure_type == Decouplio::Const::Results::PASS
    instance.pass_action
    Decouplio::Const::Results::FAIL
  elsif on_failure_type == Decouplio::Const::Results::FAIL
    instance.fail_action
    Decouplio::Const::Results::FAIL
  elsif on_failure_type == Decouplio::Const::Results::FINISH_HIM
    instance.fail_action
    Decouplio::Const::Results::FINISH_HIM
  end
end