| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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__ | ||||||||||