Class: Rung::Definition::Step

Inherits:
Object
  • Object
show all
Includes:
ValueObject
Defined in:
lib/rung/definition/step.rb

Overview

Step definition value object.

Direct Known Subclasses

NestedStep

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ValueObject

#==

Constructor Details

#initialize(action, from_block: false, run_on: :success, ignore_result: false, fail_fast: false) ⇒ Step

Returns a new instance of Step.

Parameters:

  • action (#call, Symbol)
  • from_block (Boolean) (defaults to: false)

    true when steps is defined using a Ruby block

  • run_on (:success, :failure, :any) (defaults to: :success)
    • :success - step runs on operation success

    • :failure - step runs on operation failure

    • :any - steps is always called

  • ignore_result (Boolean) (defaults to: false)

    result check behaviour

  • fail_fast (Boolean) (defaults to: false)

17
18
19
20
21
22
23
24
# File 'lib/rung/definition/step.rb', line 17

def initialize(action, from_block: false, run_on: :success, ignore_result: false, fail_fast: false)
  # rubocop:enable Metrics/LineLength
  @action = action
  @from_block = from_block
  @run_on = run_on
  @ignore_result = ignore_result
  @fail_fast = fail_fast
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action


26
27
28
# File 'lib/rung/definition/step.rb', line 26

def action
  @action
end

#from_blockObject (readonly)

Returns the value of attribute from_block


26
27
28
# File 'lib/rung/definition/step.rb', line 26

def from_block
  @from_block
end

Instance Method Details

#fail_fast?Boolean

Returns:

  • (Boolean)

53
54
55
# File 'lib/rung/definition/step.rb', line 53

def fail_fast?
  @fail_fast
end

#ignore_result?Boolean

Returns:

  • (Boolean)

49
50
51
# File 'lib/rung/definition/step.rb', line 49

def ignore_result?
  @ignore_result
end

#nested?false

Returns:

  • (false)

45
46
47
# File 'lib/rung/definition/step.rb', line 45

def nested?
  false
end

#run?(success) ⇒ Boolean

Determine whether the step should run under given operation state.

Parameters:

  • success (Boolean)

    operation current success state

Returns:

  • (Boolean)

31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rung/definition/step.rb', line 31

def run?(success)
  case @run_on
  when :success
    success
  when :failure
    !success
  when :any
    true
  else
    false
  end
end