Data-FSM

 view release on metacpan or  search on metacpan

FSM/Transition.pm  view on Meta::CPAN


Returns positive natural number.

=head2 C<initial>

 my $initial = $obj->initial;

Get inital flag..

Returns boolean (0/1).

=head2 C<name>

 my $name = $obj->name;

Get FSM state name.

Returns string.

=head2 C<to>

 my $to = $obj->to;

Get state object from which transition ends.

Returns L<Data::FSM::State> instance.

=head1 ERRORS

 new():
         From Mo::Utils::check_code():
                 Parameter '%s' must be a code.
                         Value: %s

         From Mo::utils::check_code():
                 Parameter '%s' must be a '%s' object.
                         Value: %s
                         Reference: %s

         From Mo::Utils::check_length():
                 Parameter 'name' has length greater than '100'.
                         Value: %s

         From Mo::utils::check_required():
                 Parameter '%s' is required.

         From Mo::utils::Number::check_positive_natural():
                 Parameter 'id' must be a positive natural number.
                         Value: %s

=head1 EXAMPLE

=for comment filename=create_and_print_fsm_transition.pl

 use strict;
 use warnings;

 use Data::FSM::Transition;
 use Data::FSM::State;

 my $locked = Data::FSM::State->new(
         'name' => 'Locked',
 );
 my $unlocked = Data::FSM::State->new(
         'name' => 'Unlocked',
 );
 my $obj = Data::FSM::Transition->new(
         'callback' => sub {
                 my $self = shift;
                 print 'Id: '.$self->id."\n";
         },
         'from' => $locked,
         'id' => 7,
         'name' => 'Coin',
         'to' => $unlocked,
 );

 # Print out.
 print 'Id: '.$obj->id."\n";
 print 'From: '.$obj->from->name."\n";
 print 'To: '.$obj->from->name."\n";
 print 'Name: '.$obj->name."\n";

 # Output:
 # Id: 7
 # From: Locked
 # To: Locked
 # Name: Coin

=head1 DEPENDENCIES

L<Mo>,
L<Mo::utils>,
L<Mo::utils::Number>.

=head1 REPOSITORY

L<https://github.com/michal-josef-spacek/Data-FSM>

=head1 AUTHOR

Michal Josef Špaček L<mailto:skim@cpan.org>

L<http://skim.cz>

=head1 LICENSE AND COPYRIGHT

© 2025-2026 Michal Josef Špaček

BSD 2-Clause License

=head1 VERSION

0.01

=cut



( run in 0.555 second using v1.01-cache-2.11-cpan-e1769b4cff6 )