Class: Stairway::Stairs
- Inherits:
-
Object
- Object
- Stairway::Stairs
- Includes:
- Observable
- Defined in:
- lib/stairway/stairs.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name) ⇒ Stairs
constructor
A new instance of Stairs.
- #run(context = {}, options = {}) ⇒ Object
- #run_step(name, context = {}, options = {}) ⇒ Object
- #steps ⇒ Object
- #steps=(steps) ⇒ Object
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
#name ⇒ Object
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={}, ={}) notify(context, ) @steps.each do |name, klass| begin klass.run notify(klass.context, klass.) 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={}, ={}) notify(context, ) @steps[name].run end |
#steps ⇒ Object
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 |