Machine/State.pm

filter: Statementstmt 92.8% 13 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 89.4% 17 / 19 CC 1 SCAR 2.2
CC
1
Cov
93%
main
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« DB/Nontransactional.pm ↑ Summary DB.pm »
1 package Basset::Machine::State;
2  
3 #Basset::Machine::State, copyright and (c) 2004, 2006 James A Thomason III
4 #Basset::Machine::State is distributed under the terms of the Perl Artistic License.
5  
6 =pod
7  
8 =head1 NAME
9  
10 Basset::Machine::State - used to create machine states.
11  
12 =head1 AUTHOR
13  
14 Jim Thomason, jim@jimandkoka.com
15  
16 =head1 DESCRIPTION
17  
18 Read the pod on L<Basset::Machine> for more information on machines. Basset::Machine::State
19 is a mostly abstract superclass for states defined to work with machines.
20  
21 package Some::Machine::Foozle;
22 use base 'Basset::Machine::State';
23
24 sub main {
25 my $self = shift;
26 my $machine = $self->machine;
27
28 #do interesting things.
29
30 return $machine->transition('beezle');
31 }
32  
33 states live under their machine ('My::Machine' requires 'My::Machine::State1', 'My::Machine::State2', etc.)
34 and are entered via the method ->main, which the machine calls when the state is entered.
35  
36 =cut
37  
38 2 $VERSION = '1.01';
39  
40 2 ▶use Basset::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 2 our @ISA = Basset::Object->pkg_for_type('object');
42  
43 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 =pod
47  
48 =head1 ATTRIBUTES
49  
50 =over
51  
52 =item machine
53  
54 The machine associated with this state.
55  
56 =back
57  
58 =cut
59  
60 2 __PACKAGE__->add_attr('machine');
61  
62 =pod
63  
64 =head1 METHODS
65  
66 =over
67  
68 =item main
69  
70 abstract super method. You will need to override this with the code for your state. This
71 implementation only aborts the machine.
72  
73 =back
74  
75 =cut
76  
77 0 ▶sub main {
Subroutine main: not called CC=1 SCAR=6.9
Pod documented
78 0 return shift->machine->abort("Cannot enter state : no main method", "BMS-01");
79 }
80  
81 2 1;
« DB/Nontransactional.pm ↑ Summary DB.pm »