Class: Procedure::Outcome

Inherits:
Object
  • Object
show all
Defined in:
lib/procedure/outcome.rb

Instance Method Summary collapse

Constructor Details

#initialize(step_classes) ⇒ Outcome



3
4
5
6
7
# File 'lib/procedure/outcome.rb', line 3

def initialize(step_classes)
  @step_classes = step_classes
  @failed_step = nil
  @passed_steps = []
end

Instance Method Details

#add(step) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/procedure/outcome.rb', line 9

def add(step)
  if step.passed?
    @passed_steps << step
  else
    @failed_step = step
  end
end

#failure?Boolean



29
30
31
# File 'lib/procedure/outcome.rb', line 29

def failure?
  !@failed_step.nil?
end

#failure_codeObject



23
24
25
26
27
# File 'lib/procedure/outcome.rb', line 23

def failure_code
  return unless failure?

  @failed_step.failure_code
end

#failure_messageObject



17
18
19
20
21
# File 'lib/procedure/outcome.rb', line 17

def failure_message
  return unless failure?

  @failed_step.failure_message
end

#passed_stepsObject



37
38
39
# File 'lib/procedure/outcome.rb', line 37

def passed_steps
  @passed_steps.map { |step| step.class.name }
end

#positive?Boolean



33
34
35
# File 'lib/procedure/outcome.rb', line 33

def positive?
  @failed_step.nil? && @step_classes.size == @passed_steps.size
end