Class: Stairway::Stairs

Inherits:
Object
  • Object
show all
Includes:
Observable
Defined in:
lib/stairway/stairs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Stairs

Returns a new instance of Stairs.



9
10
11
# File 'lib/stairway/stairs.rb', line 9

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/stairway/stairs.rb', line 7

def name
  @name
end

Instance Method Details

#run(context = {}, options = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/stairway/stairs.rb', line 25

def run(context={}, options={})
  notify(context, options)

  @steps.each do |name, klass|
    begin
      klass.run
      notify(klass.context, klass.options)
    rescue Stairway::Stop
      exit
    end
  end
end

#run_step(name, context = {}, options = {}) ⇒ Object



38
39
40
41
42
# File 'lib/stairway/stairs.rb', line 38

def run_step(name, context={}, options={})
  notify(context, options)

  @steps[name].run
end

#stepsObject



13
14
15
# File 'lib/stairway/stairs.rb', line 13

def steps
  @steps
end

#steps=(steps) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/stairway/stairs.rb', line 17

def steps=(steps)
  @steps = steps

  @steps.each do |name, klass|
    add_observer(klass)
  end
end