Class: Methodical::ActionItem
- Inherits:
-
Object
- Object
- Methodical::ActionItem
show all
- Extended by:
- Forwardable
- Includes:
- Executable
- Defined in:
- lib/methodical/action_item.rb
Instance Attribute Summary collapse
Attributes included from Executable
#raise_on_error
Instance Method Summary
collapse
-
#abort!(explanation = "", result = nil, error = nil, details = "") ⇒ Object
-
#checkpoint!(explanation = "", memento = nil, details = "") ⇒ Object
-
#continue? ⇒ Boolean
-
#decisive? ⇒ Boolean
-
#fail!(explanation = "", result = nil, error = nil, details = "") ⇒ Object
-
#finish!(explanation = "", result = nil, details = "") ⇒ Object
-
#human_status ⇒ Object
-
#ignored? ⇒ Boolean
-
#initialize(title) ⇒ ActionItem
constructor
A new instance of ActionItem.
-
#inspect ⇒ Object
-
#relevant? ⇒ Boolean
-
#skip!(explanation = "", details = "") ⇒ Object
-
#succeed!(explanation = "", result = nil, details = "") ⇒ Object
-
#sufficient!(explanation = "", result = nil, details = "") ⇒ Object
-
#synopsis ⇒ Object
-
#to_s ⇒ Object
-
#update!(status, explanation, result, error = nil, details = "") ⇒ Object
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
#disposition ⇒ Object
Returns the value of attribute disposition.
13
14
15
|
# File 'lib/methodical/action_item.rb', line 13
def disposition
@disposition
end
|
#error ⇒ Object
Returns the value of attribute error.
11
12
13
|
# File 'lib/methodical/action_item.rb', line 11
def error
@error
end
|
#ignored=(value) ⇒ Object
Sets the attribute ignored
12
13
14
|
# File 'lib/methodical/action_item.rb', line 12
def ignored=(value)
@ignored = value
end
|
#title ⇒ Object
Returns the value of attribute title.
10
11
12
|
# File 'lib/methodical/action_item.rb', line 10
def title
@title
end
|
#walkthrough ⇒ Object
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
74
75
76
|
# File 'lib/methodical/action_item.rb', line 74
def continue?
disposition.continuable?
end
|
#decisive? ⇒ 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_status ⇒ Object
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
66
67
68
|
# File 'lib/methodical/action_item.rb', line 66
def ignored?
@ignored
end
|
#inspect ⇒ Object
50
51
52
|
# File 'lib/methodical/action_item.rb', line 50
def inspect
"##<#{self.class.name}:#{title}:#{object_id}>"
end
|
#relevant? ⇒ 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
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
|
#synopsis ⇒ Object
45
46
47
48
|
# File 'lib/methodical/action_item.rb', line 45
def synopsis
"#{title}: #{human_status}" +
(explanation.blank? ? "." : " (#{explanation})#{ignored_suffix}.")
end
|
#to_s ⇒ Object
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
|