Module: Wizard::Controller::Concerns::Steps
- Extended by:
- ActiveSupport::Concern
- Included in:
- Wizard::Controller
- Defined in:
- lib/wizard/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
- #last_step?(current_step = nil) ⇒ Boolean
- #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
- #step ⇒ Object
- #wizard_resource_class_name ⇒ Object
- #wizard_step_per_state ⇒ Object
- #wizard_steps ⇒ Object
Instance Method Details
#current_step?(step_name) ⇒ Boolean
will return true if step passed in is the currently rendered step
72 73 74 75 76 |
# File 'lib/wizard/controller/concerns/steps.rb', line 72 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
86 87 88 89 90 |
# File 'lib/wizard/controller/concerns/steps.rb', line 86 def future_step?(step_name) return false if wizard_steps.index(step).nil? || wizard_steps.index(step_name).nil? wizard_steps.index(step) < wizard_steps.index(step_name) end |
#jump_to(goto_step) ⇒ Object
59 60 61 |
# File 'lib/wizard/controller/concerns/steps.rb', line 59 def jump_to(goto_step) @skip_to = goto_step end |
#last_step?(current_step = nil) ⇒ Boolean
126 127 128 129 130 |
# File 'lib/wizard/controller/concerns/steps.rb', line 126 def last_step?(current_step = nil) current_step = current_step || step current_step == wizard_steps.last end |
#next_step(current_step = nil) ⇒ Object
116 117 118 119 120 121 122 123 124 |
# File 'lib/wizard/controller/concerns/steps.rb', line 116 def next_step(current_step = nil) return @next_step if current_step == nil index = wizard_steps.index(current_step) step = wizard_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
100 101 102 103 104 |
# File 'lib/wizard/controller/concerns/steps.rb', line 100 def next_step?(step_name) return false if wizard_steps.index(step).nil? || wizard_steps.index(step_name).nil? wizard_steps.index(step) + 1 == wizard_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
79 80 81 82 83 |
# File 'lib/wizard/controller/concerns/steps.rb', line 79 def past_step?(step_name) return false if wizard_steps.index(step).nil? || wizard_steps.index(step_name).nil? wizard_steps.index(step) > wizard_steps.index(step_name) end |
#previous_step(current_step = nil) ⇒ Object
106 107 108 109 110 111 112 113 114 |
# File 'lib/wizard/controller/concerns/steps.rb', line 106 def previous_step(current_step = nil) return @previous_step if current_step == nil index = wizard_steps.index(current_step) step = wizard_steps.at(index - 1) if index.present? && index != 0 step ||= wizard_steps.first step end |
#previous_step?(step_name) ⇒ Boolean
will return true if the last step is the step passed in
93 94 95 96 97 |
# File 'lib/wizard/controller/concerns/steps.rb', line 93 def previous_step?(step_name) return false if wizard_steps.index(step).nil? || wizard_steps.index(step_name).nil? wizard_steps.index(step) - 1 == wizard_steps.index(step_name) end |
#skip_step ⇒ Object
63 64 65 |
# File 'lib/wizard/controller/concerns/steps.rb', line 63 def skip_step @skip_to = @next_step end |
#step ⇒ Object
67 68 69 |
# File 'lib/wizard/controller/concerns/steps.rb', line 67 def step @step end |
#wizard_resource_class_name ⇒ Object
55 56 57 |
# File 'lib/wizard/controller/concerns/steps.rb', line 55 def wizard_resource_class_name controller_name.classify end |
#wizard_step_per_state ⇒ Object
51 52 53 |
# File 'lib/wizard/controller/concerns/steps.rb', line 51 def wizard_step_per_state "#{controller_class_name}::WIZARD_STEP_PER_STATE".constantize rescue {} end |
#wizard_steps ⇒ Object
47 48 49 |
# File 'lib/wizard/controller/concerns/steps.rb', line 47 def wizard_steps "#{controller_class_name}::WIZARD_STEPS".constantize end |