Lite/Role/Workflow.pm

filter: Statementstmt 100% 26 / 26 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 4 / 4 totaltotal 100% 44 / 44 CC 4 SCAR 5.5
CC
4
Cov
100%
work
3.0
flow
2.0
BEGIN
1.0
CRAP 1.7
↑ Summary Lite.pm »
1 package Workflow::Lite::Role::Workflow;
2  
3 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use MooseX::ClassAttribute;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 4 ▶class_has _steps => ( is => 'ro', isa => 'HashRef', default => sub { { } } );
Subroutine __ANON__: called CC=1 SCAR=0.0
9  
10 4 has _step => ( is => 'rw', isa => 'Str', default => 'START' );
11 4 has _flowing => ( is => 'rw', isa => 'Bool', default => 1 );
12  
13  
14 15 ▶sub work {
Subroutine work: called CC=3 SCAR=11.0
Pod documented
15 15 my ( $self, @args ) = @_;
16  
17 15 ▶ die q!Cannot work if workflow has ended.!
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_flowing 2 13 15
18 unless $self->is_flowing;
19  
20 13 my ( $step, $steps ) = ( $self->_step, $self->_steps );
21 die q!No handler defined for step '!, $step, q!'.!
22 13 ▶ unless defined $steps->{$step};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $steps->{$step} 2 11 13
23  
24 11 my $code = $steps->{$step};
25 11 $self->$code( @args )
26 }
27  
28 8 ▶sub flow {
Subroutine flow: called CC=2 SCAR=6.9
Pod documented
29 8 my ( $self, $step ) = @_;
30  
31 8 my $steps = $self->_steps;
32 die q!Destination step '!, $step, q!' does not exist.!
33 8 ▶ unless exists $steps->{$step};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $steps->{$step} 2 6 8
34  
35 6 $self->_step( $step )
36 }
37  
38 5 ▶sub end { $_[0]->_flowing( 0 ) }
Subroutine end: called CC=1 SCAR=0.0
Pod documented
39  
40 31 ▶sub is_flowing { $_[0]->_flowing }
Subroutine is_flowing: called CC=1 SCAR=0.0
Pod documented
41  
42  
43 4 1
44 __END__
↑ Summary Lite.pm »