Sha256: 2b755dd4ce8ef7d4f7f91c10295f3385471eb876b445530e5ad908dd712b5805

Contents?: true

Size: 962 Bytes

Versions: 2

Compression:

Stored size: 962 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
  alias :wizard_steps :steps
  alias :steps_list   :steps

  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


  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


end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wicked-0.1.6 lib/wicked/controller/concerns/steps.rb
wicked-0.1.6.pre lib/wicked/controller/concerns/steps.rb