Module: Wicked::Controller::Concerns::Steps
- Extended by:
- ActiveSupport::Concern
- Included in:
- Action
- Defined in:
- lib/wicked/controller/concerns/steps.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#current_step?(step_name) ⇒ Boolean
will return true if step passed in is the currently rendered step.
-
#future_step?(step_name) ⇒ Boolean
will return true if the step passed in has already been executed by the wizard.
- #jump_to(goto_step) ⇒ Object
- #next_step(current_step = nil) ⇒ Object
-
#next_step?(step_name) ⇒ Boolean
will return true if the next step is the step passed in.
-
#past_step?(step_name) ⇒ Boolean
will return true if the step passed in has already been executed by the wizard.
- #previous_step(current_step = nil) ⇒ Object
-
#previous_step?(step_name) ⇒ Boolean
will return true if the last step is the step passed in.
- #skip_step ⇒ Object
- #skip_step? ⇒ Boolean
- #skip_steps ⇒ Object
- #step ⇒ Object
- #steps ⇒ Object (also: #wizard_steps, #steps_list)
- #steps=(wizard_steps) ⇒ Object
Instance Method Details
#current_step?(step_name) ⇒ Boolean
will return true if step passed in is the currently rendered step
17 18 19 20 |
# File 'lib/wicked/controller/concerns/steps.rb', line 17 def current_step?(step_name) return false if step_name.nil? || step.nil? step == step_name end |
#future_step?(step_name) ⇒ Boolean
will return true if the step passed in has already been executed by the wizard
29 30 31 32 |
# File 'lib/wicked/controller/concerns/steps.rb', line 29 def future_step?(step_name) return false if steps.index(step).nil? || steps.index(step_name).nil? steps.index(step) < steps.index(step_name) end |
#jump_to(goto_step) ⇒ Object
4 5 6 |
# File 'lib/wicked/controller/concerns/steps.rb', line 4 def jump_to(goto_step) @skip_to = goto_step end |
#next_step(current_step = nil) ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/wicked/controller/concerns/steps.rb', line 98 def next_step(current_step = nil) return next_step if current_step == nil index = steps.index(current_step) step = steps.at(index + 1) if index.present? step ||= :finish step end |
#next_step?(step_name) ⇒ Boolean
will return true if the next step is the step passed in
41 42 43 44 |
# File 'lib/wicked/controller/concerns/steps.rb', line 41 def next_step?(step_name) return false if steps.index(step).nil? || steps.index(step_name).nil? steps.index(step) + 1 == steps.index(step_name) end |
#past_step?(step_name) ⇒ Boolean
will return true if the step passed in has already been executed by the wizard
23 24 25 26 |
# File 'lib/wicked/controller/concerns/steps.rb', line 23 def past_step?(step_name) return false if steps.index(step).nil? || steps.index(step_name).nil? steps.index(step) > steps.index(step_name) end |
#previous_step(current_step = nil) ⇒ Object
89 90 91 92 93 94 95 |
# File 'lib/wicked/controller/concerns/steps.rb', line 89 def previous_step(current_step = nil) return previous_step if current_step == nil index = steps.index(current_step) step = steps.at(index - 1) if index.present? && index != 0 step ||= steps.first step end |
#previous_step?(step_name) ⇒ Boolean
will return true if the last step is the step passed in
35 36 37 38 |
# File 'lib/wicked/controller/concerns/steps.rb', line 35 def previous_step?(step_name) return false if steps.index(step).nil? || steps.index(step_name).nil? steps.index(step) - 1 == steps.index(step_name) end |
#skip_step ⇒ Object
8 9 10 |
# File 'lib/wicked/controller/concerns/steps.rb', line 8 def skip_step @skip_to = @next_step end |
#skip_step? ⇒ Boolean
79 80 81 82 83 |
# File 'lib/wicked/controller/concerns/steps.rb', line 79 def skip_step? return false unless params[:skip_step] return true if skip_steps.blank? skip_steps.include? step.to_sym end |
#skip_steps ⇒ Object
85 86 87 |
# File 'lib/wicked/controller/concerns/steps.rb', line 85 def skip_steps @skip_steps ||= self.class.superclass.skip_steps end |
#step ⇒ Object
12 13 14 |
# File 'lib/wicked/controller/concerns/steps.rb', line 12 def step @step end |
#steps ⇒ Object Also known as: wizard_steps, steps_list
73 74 75 |
# File 'lib/wicked/controller/concerns/steps.rb', line 73 def steps @wizard_steps end |
#steps=(wizard_steps) ⇒ Object
69 70 71 |
# File 'lib/wicked/controller/concerns/steps.rb', line 69 def steps=(wizard_steps) @wizard_steps = wizard_steps end |