Class: Methodical::ActionItem

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Executable
Defined in:
lib/methodical/action_item.rb

Direct Known Subclasses

SimpleActionItem

Instance Attribute Summary collapse

Attributes included from Executable

#raise_on_error

Instance Method Summary collapse

Methods included from Executable

#catch_disposition, #execute!, #raise_on_error?

Constructor Details

#initialize(title) ⇒ ActionItem

Returns a new instance of ActionItem.



34
35
36
37
38
39
# File 'lib/methodical/action_item.rb', line 34

def initialize(title)
  @title          = title
  @ignored        = false
  @disposition    = Disposition.new([:not_started, "", nil])
  @raise_on_error = false
end

Instance Attribute Details

#dispositionObject (readonly)

Returns the value of attribute disposition.



13
14
15
# File 'lib/methodical/action_item.rb', line 13

def disposition
  @disposition
end

#errorObject (readonly)

Returns the value of attribute error.



11
12
13
# File 'lib/methodical/action_item.rb', line 11

def error
  @error
end

#ignored=(value) ⇒ Object (writeonly)

Sets the attribute ignored

Parameters:

  • value

    the value to set the attribute ignored to.



12
13
14
# File 'lib/methodical/action_item.rb', line 12

def ignored=(value)
  @ignored = value
end

#titleObject (readonly)

Returns the value of attribute title.



10
11
12
# File 'lib/methodical/action_item.rb', line 10

def title
  @title
end

#walkthroughObject

Returns the value of attribute walkthrough.



14
15
16
# File 'lib/methodical/action_item.rb', line 14

def walkthrough
  @walkthrough
end

Instance Method Details

#abort!(explanation = "", result = nil, error = nil, details = "") ⇒ Object



122
123
124
125
# File 'lib/methodical/action_item.rb', line 122

def abort!(explanation="", result=nil, error=nil, details="")
  throw(:methodical_disposition, 
    Methodical::Disposition(:abort, explanation, result, error, details))
end

#checkpoint!(explanation = "", memento = nil, details = "") ⇒ Object



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

def checkpoint!(explanation="", memento=nil, details="")
  throw(:methodical_disposition, 
    Methodical::Disposition(:in_progress, explanation, memento, nil, details))
end

#continue?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/methodical/action_item.rb', line 74

def continue?
  disposition.continuable?
end

#decisive?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/methodical/action_item.rb', line 78

def decisive?
  !ignored? && disposition.decisive?
end

#fail!(explanation = "", result = nil, error = nil, details = "") ⇒ Object



97
98
99
100
# File 'lib/methodical/action_item.rb', line 97

def fail!(explanation="", result=nil, error=nil, details="")
  throw(:methodical_disposition, 
    Methodical::Disposition(:failed, explanation, result, error, details))
end

#finish!(explanation = "", result = nil, details = "") ⇒ Object



117
118
119
120
# File 'lib/methodical/action_item.rb', line 117

def finish!(explanation="", result=nil, details="")
  throw(:methodical_disposition, 
    Methodical::Disposition(:finish, explanation, result, nil, details))
end

#human_statusObject



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/methodical/action_item.rb', line 54

def human_status
  case status
  when :failed, :abort                     then "Failed"
  when :bad                                then "Error"
  when :succeeded, :sufficient, :finish    then "OK"
  when :in_progress                        then "In progress"
  when :not_started                        then "Not started"
  when :skipped                            then "Skipped"
  else raise "Invalid status #{status.inspect}"
  end
end

#ignored?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/methodical/action_item.rb', line 66

def ignored?
  @ignored
end

#inspectObject



50
51
52
# File 'lib/methodical/action_item.rb', line 50

def inspect
  "##<#{self.class.name}:#{title}:#{object_id}>"
end

#relevant?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/methodical/action_item.rb', line 70

def relevant?
  !ignored?
end

#skip!(explanation = "", details = "") ⇒ Object



102
103
104
105
# File 'lib/methodical/action_item.rb', line 102

def skip!(explanation="", details="")
  throw(:methodical_disposition, 
    Methodical::Disposition(:skipped, explanation, nil, nil, details))
end

#succeed!(explanation = "", result = nil, details = "") ⇒ Object

Disposition methods



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

def succeed!(explanation="", result=nil, details="")
  throw(:methodical_disposition, 
    Methodical::Disposition(:succeeded, explanation, result, nil, details))
end

#sufficient!(explanation = "", result = nil, details = "") ⇒ Object



112
113
114
115
# File 'lib/methodical/action_item.rb', line 112

def sufficient!(explanation="", result=nil, details="")
  throw(:methodical_disposition, 
    Methodical::Disposition(:sufficient, explanation, result, nil, details))
end

#synopsisObject



45
46
47
48
# File 'lib/methodical/action_item.rb', line 45

def synopsis
  "#{title}: #{human_status}" + 
    (explanation.blank? ? "." : " (#{explanation})#{ignored_suffix}.")
end

#to_sObject



41
42
43
# File 'lib/methodical/action_item.rb', line 41

def to_s
  synopsis
end

#update!(status, explanation, result, error = nil, details = "") ⇒ Object



82
83
84
85
86
87
88
89
# File 'lib/methodical/action_item.rb', line 82

def update!(status, explanation, result, error=nil, details="")
  self.status      = status
  self.explanation = explanation
  self.result      = result
  self.error       = error
  self.details     = details
  disposition
end