Class: Outback::Manager
- Inherits:
-
Object
- Object
- Outback::Manager
- Defined in:
- lib/outback/manager.rb
Constant Summary collapse
- ROLLOUT =
1- ROLLBACK =
-1
Instance Attribute Summary collapse
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#tasks ⇒ Object
readonly
Returns the value of attribute tasks.
-
#watcher ⇒ Object
writeonly
Sets the attribute watcher.
-
#workdir ⇒ Object
Returns the value of attribute workdir.
Instance Method Summary collapse
- #add_tasks(*tasks) ⇒ Object (also: #add_task)
- #attempt(task) ⇒ Object
- #current_task ⇒ Object
-
#initialize ⇒ Manager
constructor
A new instance of Manager.
- #rollback! ⇒ Object
- #rollback_from(task) ⇒ Object
- #rollout! ⇒ Object
- #rollout_from(task) ⇒ Object
Constructor Details
#initialize ⇒ Manager
Returns a new instance of Manager.
14 15 16 17 |
# File 'lib/outback/manager.rb', line 14 def initialize @tasks = [] @position = 0 end |
Instance Attribute Details
#position ⇒ Object (readonly)
Returns the value of attribute position.
10 11 12 |
# File 'lib/outback/manager.rb', line 10 def position @position end |
#tasks ⇒ Object (readonly)
Returns the value of attribute tasks.
10 11 12 |
# File 'lib/outback/manager.rb', line 10 def tasks @tasks end |
#watcher=(value) ⇒ Object (writeonly)
Sets the attribute watcher
12 13 14 |
# File 'lib/outback/manager.rb', line 12 def watcher=(value) @watcher = value end |
#workdir ⇒ Object
Returns the value of attribute workdir.
11 12 13 |
# File 'lib/outback/manager.rb', line 11 def workdir @workdir end |
Instance Method Details
#add_tasks(*tasks) ⇒ Object Also known as: add_task
19 20 21 22 23 24 |
# File 'lib/outback/manager.rb', line 19 def add_tasks( *tasks ) [*tasks].each do |task| task.workdir = @workdir unless task.workdir end @tasks += [*tasks] end |
#attempt(task) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/outback/manager.rb', line 48 def attempt( task ) method = {ROLLOUT => :rollout!, ROLLBACK => :rollback!}[@direction] ret = task.send(method) @watcher.notify(task) if @watcher return ret end |
#current_task ⇒ Object
55 56 57 |
# File 'lib/outback/manager.rb', line 55 def current_task @tasks[@position] end |
#rollback! ⇒ Object
33 34 35 36 |
# File 'lib/outback/manager.rb', line 33 def rollback! @direction = ROLLBACK run end |
#rollback_from(task) ⇒ Object
43 44 45 46 |
# File 'lib/outback/manager.rb', line 43 def rollback_from( task ) @position = @tasks.index(task) - 1 rollback! end |
#rollout! ⇒ Object
28 29 30 31 |
# File 'lib/outback/manager.rb', line 28 def rollout! @direction = ROLLOUT run end |
#rollout_from(task) ⇒ Object
38 39 40 41 |
# File 'lib/outback/manager.rb', line 38 def rollout_from( task ) @position = @tasks.index(task) rollout! end |