Class: Hekenga::SimpleTask
- Inherits:
-
Object
- Object
- Hekenga::SimpleTask
- Defined in:
- lib/hekenga/simple_task.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#downs ⇒ Object
readonly
Returns the value of attribute downs.
-
#ups ⇒ Object
readonly
Returns the value of attribute ups.
Instance Method Summary collapse
- #down! ⇒ Object
-
#initialize ⇒ SimpleTask
constructor
A new instance of SimpleTask.
- #reversible? ⇒ Boolean
- #up!(context) ⇒ Object
- #validate! ⇒ Object
Constructor Details
permalink #initialize ⇒ SimpleTask
Returns a new instance of SimpleTask.
6 7 8 9 |
# File 'lib/hekenga/simple_task.rb', line 6 def initialize @ups = [] @downs = [] end |
Instance Attribute Details
permalink #description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/hekenga/simple_task.rb', line 5 def description @description end |
permalink #downs ⇒ Object (readonly)
Returns the value of attribute downs.
4 5 6 |
# File 'lib/hekenga/simple_task.rb', line 4 def downs @downs end |
permalink #ups ⇒ Object (readonly)
Returns the value of attribute ups.
4 5 6 |
# File 'lib/hekenga/simple_task.rb', line 4 def ups @ups end |
Instance Method Details
permalink #down! ⇒ Object
21 22 23 24 25 26 |
# File 'lib/hekenga/simple_task.rb', line 21 def down! raise Hekenga::Irreversible.new(self) unless reversible? @downs.each do |block| block.call end end |
permalink #reversible? ⇒ Boolean
28 29 30 |
# File 'lib/hekenga/simple_task.rb', line 28 def reversible? downs.any? end |
permalink #up!(context) ⇒ Object
[View source]
15 16 17 18 19 |
# File 'lib/hekenga/simple_task.rb', line 15 def up!(context) @ups.each do |block| context.instance_exec(&block) end end |
permalink #validate! ⇒ Object
11 12 13 |
# File 'lib/hekenga/simple_task.rb', line 11 def validate! raise Hekenga::Invalid.new(self, :ups, "missing") unless ups.any? end |