line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: State Machine State Class |
2
|
|
|
|
|
|
|
package State::Machine::State; |
3
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
100148
|
use Bubblegum::Class; |
|
3
|
|
|
|
|
458293
|
|
|
3
|
|
|
|
|
25
|
|
5
|
3
|
|
|
3
|
|
1574199
|
use Function::Parameters; |
|
3
|
|
|
|
|
6476
|
|
|
3
|
|
|
|
|
31
|
|
6
|
3
|
|
|
3
|
|
3041
|
use State::Machine::Failure::Transition::Unknown; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
118
|
|
7
|
3
|
|
|
3
|
|
2197
|
use State::Machine::Transition; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
133
|
|
8
|
3
|
|
|
3
|
|
38
|
use Try::Tiny; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
272
|
|
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
62
|
use Bubblegum::Constraints -typesof; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
25
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.07'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'name' => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
isa => typeof_string, |
17
|
|
|
|
|
|
|
required => 1 |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has 'next' => ( |
21
|
|
|
|
|
|
|
is => 'rw', |
22
|
|
|
|
|
|
|
isa => typeof_string, |
23
|
|
|
|
|
|
|
required => 0 |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has 'transitions' => ( |
27
|
|
|
|
|
|
|
is => 'ro', |
28
|
|
|
|
|
|
|
isa => typeof_hashref, |
29
|
|
|
|
|
|
|
default => sub {{}} |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
2
|
1
|
354
|
method add_transition { |
|
2
|
|
|
|
|
3
|
|
33
|
2
|
|
|
|
|
4
|
my $trans = pop; |
34
|
2
|
|
|
|
|
5
|
my $name = shift; |
35
|
|
|
|
|
|
|
|
36
|
2
|
50
|
|
|
|
24
|
if ($trans->isa('State::Machine::Transition')) { |
37
|
2
|
|
33
|
|
|
18
|
$name //= $trans->name; |
38
|
2
|
|
|
|
|
32
|
$self->transitions->set($name => $trans); |
39
|
2
|
|
|
|
|
536
|
return $trans; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# transition not found |
43
|
|
|
|
|
|
|
State::Machine::Failure::Transition::Unknown->throw( |
44
|
0
|
|
|
|
|
|
transition_name => $name, |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
0
|
1
|
|
method remove_transition { |
|
0
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $name = shift; |
50
|
|
|
|
|
|
|
|
51
|
0
|
0
|
|
|
|
|
if ($self->transitions->get($name->asa_string)) { |
52
|
0
|
|
|
|
|
|
return $self->transitions->delete($name); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# transition not found |
56
|
|
|
|
|
|
|
State::Machine::Failure::Transition::Unknown->throw( |
57
|
0
|
|
|
|
|
|
transition_name => $name, |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |