The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

State::Machine::Transition - State Machine State Transition Class

VERSION

version 0.07

SYNOPSIS

    use State::Machine::Transition;

    my $trans = State::Machine::Transition->new(
        name   => 'resume',
        result => State::Machine::State->new(name => 'awake')
    );

    $trans->hook(during => sub {
        my ($trans, $state, @args) = @_;
        # do something during resume
    });

DESCRIPTION

State::Machine::Transition represents a state transition and it's resulting state.

ATTRIBUTES

executable

    my $executable = $trans->executable;
    $trans->executable(1);

The executable flag determines whether a transition can be execute.

hooks

    my $hooks = $trans->hooks;

The hooks attribute contains the collection of triggers and events to be fired when the transition is executed. The hook method should be used to configure any hooks into the transition processing.

name

    my $name = $trans->name;
    $name = $trans->name('suicide');

The name of the transition. The value can be any scalar value.

result

    my $state = $trans->result;
    $state = $trans->result(State::Machine::State->new(...));

The result represents the resulting state of a transition. The value must be a State::Machine::State object.

METHODS

hook

    $trans = $trans->hook(during => sub {...});
    $trans->hook(before => sub {...});
    $trans->hook(after => sub {...});

The hook method registers a new hook in the append-only hooks collection to be fired when the transition is executed. The method requires an event name, either before, during, or after, and a code reference.

AUTHOR

Al Newkirk <anewkirk@ana.io>

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.