| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package Class::Workflow::State::AutoApply; | ||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use Carp qw/croak/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use Scalar::Util qw/refaddr/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 5 | has auto_transition => ( | |||||||||||||||||||||||||||
| 10 | does => "Class::Workflow::Transition", | ||||||||||||||||||||||||||||
| 11 | accessor => "auto_transition", | ||||||||||||||||||||||||||||
| 12 | predicate => "has_auto_transition", | ||||||||||||||||||||||||||||
| 13 | required => 0, | ||||||||||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 25 | ▶ | around transitions => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.8
| |||||||||||||||||||||||||||||
| 17 | 25 | my $next = shift; | |||||||||||||||||||||||||||
| 18 | 25 | my ( $self, @transitions ) = @_; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 25 | my @ret = $self->$next( @transitions ); | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # if the auto transition was not in ->transitions( @set ) then delete it | ||||||||||||||||||||||||||||
| 23 | 25 | ▶ | if ( @transitions and my $auto = $self->auto_transition ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@transitions and my $auto = $self->auto_transition
MC/DC0%0/2
@transitions and my $auto = $self->auto_transition
@transitions
my $auto = $self->auto_transition
Truth table66%2/3
A and B
A= @transitionsB= my $auto = $self->auto_transition
| |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | $self->auto_transition(undef) unless grep { $_ == $auto } @transitions; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 25 | ▶ | if ( my $auto = $self->auto_transition ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 1 | return $auto, @ret; | |||||||||||||||||||||||||||
| 29 | } else { | ||||||||||||||||||||||||||||
| 30 | 24 | return @ret; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | 5 | }; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 13 | ▶ | around has_transition => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=22.1
| |||||||||||||||||||||||||||||
| 35 | 13 | my $next = shift; | |||||||||||||||||||||||||||
| 36 | 13 | my ( $self, $transition ) = @_; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 13 | ▶ | if ( my $auto = $self->auto_transition ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 2 | ▶ | if ( ref $transition ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 2 | ▶ | return 1 if refaddr($auto) == refaddr($transition); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | } else { | ||||||||||||||||||||||||||||
| 42 | 0 | ▶ | return 1 if $auto->can("name") and $auto->name eq $transition; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$auto->can("name") and $auto->name eq $transition
MC/DC0%0/2
$auto->can("name") and $auto->name eq $transition
$auto->can("name")
$auto->name eq $transition
Truth table0%0/3
A and B
A= $auto->can("name")B= $auto->name eq $transition
| |||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 11 | return $self->$next($transition); | |||||||||||||||||||||||||||
| 47 | 5 | }; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 11 | ▶ | around accept_instance => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 50 | 11 | my $next = shift; | |||||||||||||||||||||||||||
| 51 | 11 | my ( $self, $orig_instance, @args ) = @_; | |||||||||||||||||||||||||||
| 52 | 11 | my $instance = $self->$next( $orig_instance, @args ); | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 11 | ▶ | return $self->apply_auto_transition( $instance, @args ) || $instance; | ||||||||||||||||||||||||||
|
Condition66%2/3
$self->apply_auto_transition($instance, @args) || $instance
MC/DC0%0/2
$self->apply_auto_transition($instance, @args) || $instance
$self->apply_auto_transition($instance, @args)
$instance
Truth table66%2/3
A || B
A= $self->apply_auto_transition($instance, @args)B= $instance
| |||||||||||||||||||||||||||||
| 55 | 5 | }; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 11 | ▶ | sub apply_auto_transition { | ||||||||||||||||||||||||||
|
Subroutine
apply_auto_transition: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 58 | 11 | my ( $self, $instance, @args ) = @_; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 11 | ▶ | if ( my $auto_transition = $self->auto_transition ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 2 | return $auto_transition->apply( $instance, @args ); | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 9 | return; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 5 | __PACKAGE__; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | __END__ | ||||||||||||||||||||||||||||