Class: Methodical::Disposition

Inherits:
Object
  • Object
show all
Defined in:
lib/methodical/disposition.rb

Overview

A Disposition represents the status of an ActionItem (step)

Explanation of statuses:

  • not_started: The action has not yet been performed
  • in_progress: The action has been started, and has not finished.
  • succeeded: The action succeeded. If all actions succeed, the walkthrough is considered a success.
  • failed: The action failed. The walkthrough will fail unless the "ignored" flag was set; but the walkthrough will not be halted.
  • sufficient: The action succeeded. Later steps will be executed, but the walkthrough will be a success even if there are later failures.
  • finish: The action succeeded. No more steps will be performed.
  • abort: The action failed, and no more steps will be performed.
  • bad: An error occured outside of the range of any expected failure modes. The walkthrough will continue, but will be marked as failed.
  • skipped: The action was skipped. The "explanation" field should contain the reason for skipping the action.

Constant Summary collapse

VALID_STATUSES =
[
  :not_started,
  :in_progress,
  :succeeded,
  :failed,
  :sufficient,
  :finish,
  :abort,
  :bad,
  :skipped
]

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Disposition



59
60
61
62
63
# File 'lib/methodical/disposition.rb', line 59

def initialize(*args)
  base_initialize(*args)
  self.details ||= ""
  validate!
end

Instance Method Details

#bad?Boolean



80
81
82
# File 'lib/methodical/disposition.rb', line 80

def bad?
  status == :bad
end

#base_initializeObject



58
# File 'lib/methodical/disposition.rb', line 58

alias_method :base_initialize, :initialize

#continuable?Boolean



92
93
94
# File 'lib/methodical/disposition.rb', line 92

def continuable?
  !halted?
end

#decisive?Boolean



100
101
102
# File 'lib/methodical/disposition.rb', line 100

def decisive?
  [:sufficient, :finish, :failed, :bad, :abort].include?(status)
end

#done?Boolean



88
89
90
# File 'lib/methodical/disposition.rb', line 88

def done?
  succeeded? || failed? || skipped?
end

#done_and_ok?Boolean



104
105
106
# File 'lib/methodical/disposition.rb', line 104

def done_and_ok?
  done? && ok?
end

#failed?Boolean



72
73
74
# File 'lib/methodical/disposition.rb', line 72

def failed?
  [:failed, :bad, :abort].include?(status)
end

#halted?Boolean



96
97
98
# File 'lib/methodical/disposition.rb', line 96

def halted?
  status == :abort || status == :finish
end

#merge(params) ⇒ Object



108
109
110
# File 'lib/methodical/disposition.rb', line 108

def merge(params)
  params.inject(self.class.new(self)) {|d, (k,v)| d[k] = v; d}
end

#ok?Boolean



68
69
70
# File 'lib/methodical/disposition.rb', line 68

def ok?
  !failed?
end

#skipped?Boolean



84
85
86
# File 'lib/methodical/disposition.rb', line 84

def skipped?
  status == :skipped
end

#succeeded?Boolean



76
77
78
# File 'lib/methodical/disposition.rb', line 76

def succeeded?
  [:succeeded, :sufficient, :finish].include?(status)
end