Class-StateMachine
view release on metacpan or search on metacpan
0.23 Apr 16, 2013
- add support for state_changed_on_call
- add support for on_leave_state feature
- some internal lexical variables from Class::StateMachine were
leaking into the environment used to evaluate state names from
OnState declarations
0.22 Mar 25, 2013
- add support for the set_state_isa and state_isa methods
- improve detection of state changes from callbacks
(i.e. enter_state, leave_state, delayed events, etc.)
*** incompatible change ***
- calling state with the same state as the current one now
triggers callbacks
0.21 Jan 21, 2013
- add support for delay_once_until_next_state method
0.20 Nov 27, 2012
- work around bug on the pure-perl version of Package::Stash
0.19 Jul 10, 2012
- delayed action processing was broken and could loop forever
when delayed actions were created from previous delayed action
lib/Class/StateMachine.pm view on Meta::CPAN
L</leave_state> and L</enter_state> are called if they are defined.
Note that they can be defined using the C<OnState> attribute:
package Dog;
...
sub enter_state :OnState(angry) { shift->bark }
sub enter_state :OnState(tired) { shift->lie_down }
The method C<on_leave_state> can also be used to register per-object
callbacks that are run just before changing the object state.
=head2 API
These are the methods available from Class::StateMachine:
=over 4
=item Class::StateMachine::bless($obj, $class, $state)
=item $obj-E<gt>bless($class)
lib/Class/StateMachine.pm view on Meta::CPAN
C<$callback> may be a reference to a subroutine or a method name. It
is called respectively as follows:
$callback->(@args); # $callback is a CODE reference
$self->$callback(@args); # $callback is a method name
If the calling the C<leave_state> method is also defined, it is called first.
The method may be called repeatedly from the same state and the
callbacks will be executed in FIFO order.
=item $self->delay_until_next_state
=item $self->delay_until_next_state($method_name)
=item $self->delay_until_next_state($code_ref)
This function allows to save a code reference or a method name that
will be called after the next state transition from the C<state>
method just after C<enter_state>.
( run in 1.349 second using v1.01-cache-2.11-cpan-9b1e4054eb1 )