Module: MultiStep::ActsAsMultiStep

Extended by:
ActiveSupport::Concern
Defined in:
lib/multi-step/acts-as-multi-step.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#complete!Object



28
29
30
# File 'lib/multi-step/acts-as-multi-step.rb', line 28

def complete!
  update_attribute(:step, completed)
end

#complete?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/multi-step/acts-as-multi-step.rb', line 24

def complete?
  step.eql? completed
end

#completedObject



20
21
22
# File 'lib/multi-step/acts-as-multi-step.rb', line 20

def completed
  "Completed"
end

#current_stepObject



32
33
34
# File 'lib/multi-step/acts-as-multi-step.rb', line 32

def current_step
  step || klass.form_steps_sanitized.first
end

#current_step?(step) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/multi-step/acts-as-multi-step.rb', line 40

def current_step?(step)
  current_step.eql?(step)
end

#first_step?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/multi-step/acts-as-multi-step.rb', line 44

def first_step?
  current_step? klass.form_steps_sanitized.first
end

#last_step?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/multi-step/acts-as-multi-step.rb', line 48

def last_step?
  current_step? klass.form_steps_sanitized.last
end

#next_step!Object



52
53
54
55
56
57
58
# File 'lib/multi-step/acts-as-multi-step.rb', line 52

def next_step!
  if current_step.eql?(klass.form_steps_sanitized.last)
    complete!
  else
    update_attribute(:step, klass.form_steps_sanitized[klass.form_steps_sanitized.find_index(current_step) + 1])
  end
end

#on?(step) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/multi-step/acts-as-multi-step.rb', line 36

def on?(step)
  current_step.eql?(step.to_s.parameterize)
end

#previous_step!Object



60
61
62
63
64
# File 'lib/multi-step/acts-as-multi-step.rb', line 60

def previous_step!
  if !current_step.eql?(klass.form_steps_sanitized.first) && !complete?
    update_attribute(:step, klass.form_steps_sanitized[klass.form_steps_sanitized.find_index(current_step) - 1])
  end
end