<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    State::Machine - Simple State Machine Implementation

VERSION
    version 0.04

SYNOPSIS
        use State::Machine;
        use State::Machine::State;
        use State::Machine::Transition;

        # light-switch circular-state example

        my $is_on  = State::Machine::State-&gt;new(name =&gt; 'is_on');
        my $is_off = State::Machine::State-&gt;new(name =&gt; 'is_off');

        my $turn_on  = State::Machine::Transition-&gt;new(
            name   =&gt; 'turn_on',
            result =&gt; $is_on
        );
        my $turn_off = State::Machine::Transition-&gt;new(
            name   =&gt; 'turn_off',
            result =&gt; $is_off
        );

        $is_on-&gt;add_transition($turn_off); # on -&gt; turn off
        $is_off-&gt;add_transition($turn_on); # off -&gt; turn on

        my $lightswitch = State::Machine-&gt;new(
            topic =&gt; 'typical light switch',
            state =&gt; $is_off
        );

        $lightswitch-&gt;apply('turn_off');
        $lightswitch-&gt;status; # is_off

DESCRIPTION
    A finite-state machine (FSM) or finite-state automaton (plural:
    automata), or simply a state machine, is an abstract machine that can be
    in one of a finite number of states. The machine is in only one state at
    a time. It can change from one state to another when initiated by a
    triggering event or condition; this is called a transition.
    State::Machine is a system for creating state machines and managing
    their transitions; It is also a great mechanism for enforcing and
    tracking workflow, especially in distributed computing.

    State machines are useful for modeling systems with perform a
    predetermined sequence of event and result in deterministic state.
    State::Machine, as you might expect, allows for the definition of
    events, states, state transitions and user defined actions that can be
    executed before or after transitions. All features of the state machine
    itself can be configured via a DSL, State::Machine::Simple. Note: This
    is an early release available for testing and feedback and as such is
    subject to change.

ATTRIBUTES
  state
        my $state = $machine-&gt;state;
        $state = $machine-&gt;state(State::Machine::State-&gt;new(...));

    The current state of the state machine. The value should be a
    State::Machine::State object.

  topic
        my $topic = $machine-&gt;topic;
        $topic = $machine-&gt;topic('Take over the world');

    The topic or purpose of the state machine. The value can be any
    arbitrary string describing intent.

METHODS
  apply
        my $state = $machine-&gt;apply('transition_name');
        $state = $machine-&gt;apply; # apply known next transition

    The apply method transitions the state machine from the current state
    into the resulting state. If the apply method is called without a
    transition name, the machine will transition into the next known state
    of the current state.

  next
        my $transition_name = $machine-&gt;next;

    The next method returns the name of the next known transition of the
    current state if exists, otherwise it will return undefined.

  status
        my $state_name = $machine-&gt;status;

    The status method returns the name of the current state.

AUTHOR
    Al Newkirk &lt;anewkirk@ana.io&gt;

COPYRIGHT AND LICENSE
    This software is copyright (c) 2014 by Al Newkirk.

    This is free software; you can redistribute it and/or modify it under
    the same terms as the Perl 5 programming language system itself.

</pre></body></html>