Sha256: 55972ac034633029b5292659ddb43c57ed933a2c837eb289e8b91c0efc82a0ef
Contents?: true
Size: 1.4 KB
Versions: 7
Compression:
Stored size: 1.4 KB
Contents
# coding: utf-8 # frozen_string_literal: true module Stealth module Flow class Specification attr_reader :flow_name attr_accessor :states, :initial_state def initialize(flow_name, &specification) @states = Hash.new @flow_name = flow_name instance_eval(&specification) end def state_names states.keys end private def state(name, fails_to: nil, redirects_to: nil, **opts) fail_state = get_fail_or_redirect_state(fails_to) redirect_state = get_fail_or_redirect_state(redirects_to) new_state = Stealth::Flow::State.new( name: name, spec: self, fails_to: fail_state, redirects_to: redirect_state, opts: opts ) @initial_state = new_state if @states.empty? @states[name.to_sym] = new_state end def get_fail_or_redirect_state(specified_state) if specified_state.present? session = Stealth::Session.new if Stealth::Session.is_a_session_string?(specified_state) session.session = specified_state else session.session = Stealth::Session.canonical_session_slug( flow: flow_name, state: specified_state ) end return session end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems