Sha256: 902c50331981e11a5faee5f8202cdf94f81d5fde858dd6efb787fc331b0d92c1

Contents?: true

Size: 778 Bytes

Versions: 2

Compression:

Stored size: 778 Bytes

Contents

module Wicked::Controller::Concerns::Steps
  extend ActiveSupport::Concern


  def jump_to(goto_step)
    @skip_to = goto_step
  end

  def skip_step
    @skip_to = @next_step
  end

  def step
    @step
  end

  module ClassMethods
    def steps=(steps)
      @wizard_steps = steps
    end

    def steps(*steps_to_set)
      @wizard_steps = steps_to_set unless steps_to_set.blank?
      @wizard_steps
    end
  end

  def steps
    self.class.steps
  end


  def next_step(current_step)
    index = steps.index(current_step)
    step = steps.at(index + 1) if index.present?
    step ||= :finish
    step
  end

  def previous_step(current_step)
    index = steps.index(current_step)
    step = steps.at(index - 1) if index.present?
    step ||= steps.at(0)
    step
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wicked-with-previous-support-0.2 lib/wicked/controller/concerns/steps.rb
wicked-with-previous-support-0.1 lib/wicked/controller/concerns/steps.rb