Class: Codeprimate::Wizard::Base
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Codeprimate::Wizard::Base
- Defined in:
- lib/wizard_controller.rb
Class Attribute Summary collapse
-
.abort_path ⇒ Object
Returns the value of attribute abort_path.
-
.finish_path ⇒ Object
Returns the value of attribute finish_path.
-
.wizard_default_error ⇒ Object
Returns the value of attribute wizard_default_error.
-
.wizard_steps ⇒ Object
Returns the value of attribute wizard_steps.
Class Method Summary collapse
-
.define_steps(*args) ⇒ Object
Define steps of the wizard.
-
.set_abort_path(p) ⇒ Object
Set the URL that a user is redirected to after aborting the Wizard.
-
.set_default_error(e) ⇒ Object
Set the flash message a user sees when a process_action method returns false.
-
.set_finish_path(p) ⇒ Object
Set the URL that a user is redirected to after finishing the Wizard.
Instance Method Summary collapse
-
#direct_step ⇒ Object
Internal.
-
#finish_path=(p) ⇒ Object
Assign finish path.
-
#index ⇒ Object
Internal.
-
#next_step ⇒ Object
Internal.
-
#previous_step ⇒ Object
Internal.
-
#reset ⇒ Object
Public action to reset the wizard.
Class Attribute Details
.abort_path ⇒ Object
Returns the value of attribute abort_path.
94 95 96 |
# File 'lib/wizard_controller.rb', line 94 def abort_path @abort_path end |
.finish_path ⇒ Object
Returns the value of attribute finish_path.
94 95 96 |
# File 'lib/wizard_controller.rb', line 94 def finish_path @finish_path end |
.wizard_default_error ⇒ Object
Returns the value of attribute wizard_default_error.
94 95 96 |
# File 'lib/wizard_controller.rb', line 94 def wizard_default_error @wizard_default_error end |
.wizard_steps ⇒ Object
Returns the value of attribute wizard_steps.
94 95 96 |
# File 'lib/wizard_controller.rb', line 94 def wizard_steps @wizard_steps end |
Class Method Details
.define_steps(*args) ⇒ Object
Define steps of the wizard.
Should be an array of symbols.
99 100 101 |
# File 'lib/wizard_controller.rb', line 99 def define_steps(*args) self.wizard_steps = args end |
.set_abort_path(p) ⇒ Object
Set the URL that a user is redirected to after aborting the Wizard.
Should be a string
113 114 115 |
# File 'lib/wizard_controller.rb', line 113 def set_abort_path(p) self.abort_path = p end |
.set_default_error(e) ⇒ Object
Set the flash message a user sees when a process_action method returns false
Should be a string
120 121 122 |
# File 'lib/wizard_controller.rb', line 120 def set_default_error(e) self.wizard_default_error = e end |
.set_finish_path(p) ⇒ Object
Set the URL that a user is redirected to after finishing the Wizard.
Should be a string
106 107 108 |
# File 'lib/wizard_controller.rb', line 106 def set_finish_path(p) self.finish_path = p end |
Instance Method Details
#direct_step ⇒ Object
Internal.
154 155 156 157 158 159 160 161 162 |
# File 'lib/wizard_controller.rb', line 154 def direct_step step = params[:id].to_i if step_completed(step) set_current_wizard_step([1, step].max) else flash[:error] ||= self.class.wizard_default_error end redirect_to :action => :index end |
#finish_path=(p) ⇒ Object
Assign finish path.
Accepts a string.
173 174 175 176 177 178 |
# File 'lib/wizard_controller.rb', line 173 def finish_path=(p) unless p.blank? session[:finish_path] = p end finish_path end |
#index ⇒ Object
Internal.
128 129 130 131 132 133 134 |
# File 'lib/wizard_controller.rb', line 128 def index if finished handle_finished_wizard else handle_unfinished_wizard end end |
#next_step ⇒ Object
Internal.
137 138 139 140 141 142 143 144 145 |
# File 'lib/wizard_controller.rb', line 137 def next_step if step_completed incr_step else flash[:error] ||= self.class.wizard_default_error end self.finish_path = params[:redirect] unless params[:redirect].blank? redirect_to :action => :index end |
#previous_step ⇒ Object
Internal.
148 149 150 151 |
# File 'lib/wizard_controller.rb', line 148 def previous_step decr_step redirect_to :action => :index end |
#reset ⇒ Object
Public action to reset the wizard
165 166 167 168 |
# File 'lib/wizard_controller.rb', line 165 def reset reset_wizard redirect_to :action => :index end |