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
#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
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/hekenga/simple_task.rb', line 5 def description @description end |
#downs ⇒ Object (readonly)
Returns the value of attribute downs.
4 5 6 |
# File 'lib/hekenga/simple_task.rb', line 4 def downs @downs end |
#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
#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 |
#reversible? ⇒ Boolean
28 29 30 |
# File 'lib/hekenga/simple_task.rb', line 28 def reversible? downs.any? end |
#up!(context) ⇒ Object
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 |