Class: Codeprimate::Wizard::Base

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/wizard_controller.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.abort_pathObject

Returns the value of attribute abort_path.



14
15
16
# File 'lib/wizard_controller.rb', line 14

def abort_path
  @abort_path
end

.finish_pathObject

Returns the value of attribute finish_path.



14
15
16
# File 'lib/wizard_controller.rb', line 14

def finish_path
  @finish_path
end

.wizard_default_errorObject

Returns the value of attribute wizard_default_error.



14
15
16
# File 'lib/wizard_controller.rb', line 14

def wizard_default_error
  @wizard_default_error
end

.wizard_stepsObject

Returns the value of attribute wizard_steps.



14
15
16
# File 'lib/wizard_controller.rb', line 14

def wizard_steps
  @wizard_steps
end

Class Method Details

.define_steps(*args) ⇒ Object



16
17
18
# File 'lib/wizard_controller.rb', line 16

def define_steps(*args)
  self.wizard_steps = args
end

.set_abort_path(p) ⇒ Object



24
25
26
# File 'lib/wizard_controller.rb', line 24

def set_abort_path(p)
  self.abort_path = p
end

.set_default_error(e) ⇒ Object



28
29
30
# File 'lib/wizard_controller.rb', line 28

def set_default_error(e)
  self.wizard_default_error = e
end

.set_finish_path(p) ⇒ Object



20
21
22
# File 'lib/wizard_controller.rb', line 20

def set_finish_path(p)
  self.finish_path = p
end

Instance Method Details

#indexObject



39
40
41
42
43
44
45
# File 'lib/wizard_controller.rb', line 39

def index
  if finished
    handle_finished_wizard
  else
    handle_unfinished_wizard
  end
end

#next_stepObject



47
48
49
50
51
52
53
54
55
# File 'lib/wizard_controller.rb', line 47

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_stepObject



57
58
59
60
# File 'lib/wizard_controller.rb', line 57

def previous_step
  decr_step
  redirect_to :action => :index
end

#resetObject



62
63
64
65
# File 'lib/wizard_controller.rb', line 62

def reset
  reset_wizard
  redirect_to :action => :index
end

#set_abort_path(p) ⇒ Object

PUBLIC ACTIONS



35
36
37
# File 'lib/wizard_controller.rb', line 35

def set_abort_path(p)
  self.abort_path = p
end