line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Class::Workflow::Transition::Strict; |
4
|
1
|
|
|
1
|
|
1509
|
use Moose::Role; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
before apply => sub { |
7
|
|
|
|
|
|
|
my ( $self, $instance, @args ) = @_; |
8
|
|
|
|
|
|
|
my $state = $instance->state; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
unless ( $state->has_transition( $self ) ) { |
11
|
|
|
|
|
|
|
die "$self is not in $instance\'s current state ($state)" |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
}; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
__PACKAGE__; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
__END__ |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=pod |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 NAME |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Class::Workflow::Transition::Strict - Verify that the transition is in the |
24
|
|
|
|
|
|
|
instance's current state before applying. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
package MyTransition; |
29
|
|
|
|
|
|
|
use Moose; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
with qw/ |
32
|
|
|
|
|
|
|
Class::Workflow::Transition |
33
|
|
|
|
|
|
|
Class::Workflow::Transition::Strict |
34
|
|
|
|
|
|
|
/; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 DESCRIPTION |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
This mixin role provides a L<Moose/before> wrapper around the C<apply> method, |
39
|
|
|
|
|
|
|
that verifies that the transition is present in the current state of the |
40
|
|
|
|
|
|
|
instance. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Normally you use the state introspection methods to retrieve transition |
43
|
|
|
|
|
|
|
objects from the state of the instance directly, but this role adds an extra |
44
|
|
|
|
|
|
|
level of protection. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|