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

Instance Method Details

#current_step?(step_name) ⇒ Boolean

will return true if step passed in is the currently rendered step

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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_stepObject



8
9
10
# File 'lib/wicked/controller/concerns/steps.rb', line 8

def skip_step
  @skip_to = @next_step
end

#skip_step?Boolean

Returns:

  • (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_stepsObject



85
86
87
# File 'lib/wicked/controller/concerns/steps.rb', line 85

def skip_steps
  @skip_steps ||= self.class.superclass.skip_steps
end

#stepObject



12
13
14
# File 'lib/wicked/controller/concerns/steps.rb', line 12

def step
  @step
end

#stepsObject 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