Sha256: 921c9ebada8a8a0ac9a648140225e21522ab03fada08d076dc3d001a439642f2

Contents?: true

Size: 594 Bytes

Versions: 1

Compression:

Stored size: 594 Bytes

Contents

module Forminator
  class Flow
    attr_reader :steps, :current_step

    def initialize(steps:)
      @steps = steps
      @current_step = initial_step
    end

    def next_step
      steps[steps.index(current_step) + 1]
    end

    def previous_step
      # TODO: there is no previous step??
      steps[steps.index(current_step) - 1]
    end

    def initial_step
      steps.first
    end

    def add(step:)
      raise Forminator::InvalidStep unless step.ancestors.include?(Forminator::Step)
      steps << step
    end

    def remove(step:)
      steps.delete(step)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
forminator-0.1.0 lib/forminator/flow.rb