State::Machine::Transition - State Machine State Transition Class
version 0.07
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 });
State::Machine::Transition represents a state transition and it's resulting state.
my $executable = $trans->executable; $trans->executable(1);
The executable flag determines whether a transition can be execute.
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.
hook
my $name = $trans->name; $name = $trans->name('suicide');
The name of the transition. The value can be any scalar value.
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.
$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.
before
during
after
Al Newkirk <anewkirk@ana.io>
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.
To install State::Machine, copy and paste the appropriate command in to your terminal.
cpanm
cpanm State::Machine
CPAN shell
perl -MCPAN -e shell install State::Machine
For more information on module installation, please visit the detailed CPAN module installation guide.