Sha256: c4b30262eb0f2d09ce580506a1045fe914fb8832e386c74322a696a5c391f31e

Contents?: true

Size: 740 Bytes

Versions: 15

Compression:

Stored size: 740 Bytes

Contents

# coding: utf-8
# frozen_string_literal: true

module Stealth
  module Flow
    class Specification
      attr_accessor :states, :initial_state

      def initialize(&specification)
        @states = Hash.new
        instance_eval(&specification)
      end

      def state_names
        states.keys
      end

      private

        def state(name, fails_to: nil)
          fail_state = nil
          if fails_to.present?
            fail_state = Stealth::Flow::State.new(fails_to, self)
          end

          new_state = Stealth::Flow::State.new(name, self, fail_state)
          @initial_state = new_state if @states.empty?
          @states[name.to_sym] = new_state
          @scoped_state = new_state
        end

    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
stealth-1.0.4 lib/stealth/flow/specification.rb
stealth-1.0.3 lib/stealth/flow/specification.rb
stealth-1.0.2 lib/stealth/flow/specification.rb
stealth-1.0.1 lib/stealth/flow/specification.rb
stealth-1.0.0 lib/stealth/flow/specification.rb
stealth-1.0.0.rc1 lib/stealth/flow/specification.rb
stealth-1.0.0.pre2 lib/stealth/flow/specification.rb
stealth-1.0.0.pre1 lib/stealth/flow/specification.rb
stealth-0.10.6 lib/stealth/flow/specification.rb
stealth-0.10.5 lib/stealth/flow/specification.rb
stealth-0.10.4 lib/stealth/flow/specification.rb
stealth-0.10.3 lib/stealth/flow/specification.rb
stealth-0.10.2 lib/stealth/flow/specification.rb
stealth-0.10.1 lib/stealth/flow/specification.rb
stealth-0.10.0 lib/stealth/flow/specification.rb