Class: Outback::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/outback/manager.rb

Constant Summary collapse

ROLLOUT =
1
ROLLBACK =
-1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeManager

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

#positionObject (readonly)

Returns the value of attribute position.



10
11
12
# File 'lib/outback/manager.rb', line 10

def position
  @position
end

#tasksObject (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

Parameters:

  • value

    the value to set the attribute watcher to.



12
13
14
# File 'lib/outback/manager.rb', line 12

def watcher=(value)
  @watcher = value
end

#workdirObject

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_taskObject



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