Class: Forminator::Flow
- Inherits:
-
Object
- Object
- Forminator::Flow
- Defined in:
- lib/forminator/flow.rb
Instance Attribute Summary collapse
-
#current_step ⇒ Object
readonly
Returns the value of attribute current_step.
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
- #add(step:) ⇒ Object
- #initial_step ⇒ Object
-
#initialize(steps:) ⇒ Flow
constructor
A new instance of Flow.
- #next_step ⇒ Object
- #previous_step ⇒ Object
- #remove(step:) ⇒ Object
Constructor Details
#initialize(steps:) ⇒ Flow
Returns a new instance of Flow.
5 6 7 8 |
# File 'lib/forminator/flow.rb', line 5 def initialize(steps:) @steps = steps @current_step = initial_step end |
Instance Attribute Details
#current_step ⇒ Object (readonly)
Returns the value of attribute current_step.
3 4 5 |
# File 'lib/forminator/flow.rb', line 3 def current_step @current_step end |
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
3 4 5 |
# File 'lib/forminator/flow.rb', line 3 def steps @steps end |
Instance Method Details
#add(step:) ⇒ Object
23 24 25 26 |
# File 'lib/forminator/flow.rb', line 23 def add(step:) raise Forminator::InvalidStep unless step.ancestors.include?(Forminator::Step) steps << step end |
#initial_step ⇒ Object
19 20 21 |
# File 'lib/forminator/flow.rb', line 19 def initial_step steps.first end |
#next_step ⇒ Object
10 11 12 |
# File 'lib/forminator/flow.rb', line 10 def next_step steps[steps.index(current_step) + 1] end |
#previous_step ⇒ Object
14 15 16 17 |
# File 'lib/forminator/flow.rb', line 14 def previous_step # TODO: there is no previous step?? steps[steps.index(current_step) - 1] end |
#remove(step:) ⇒ Object
28 29 30 |
# File 'lib/forminator/flow.rb', line 28 def remove(step:) steps.delete(step) end |