line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: State Machine State Transition Class |
2
|
|
|
|
|
|
|
package State::Machine::Transition; |
3
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
18
|
use Bubblegum::Class; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
25
|
|
5
|
3
|
|
|
3
|
|
34671
|
use Function::Parameters; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
33
|
|
6
|
3
|
|
|
3
|
|
4679
|
use State::Machine::Failure::Transition::Hook; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
164
|
|
7
|
3
|
|
|
3
|
|
31
|
use State::Machine::State; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
87
|
|
8
|
3
|
|
|
3
|
|
16
|
use Try::Tiny; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
314
|
|
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
20
|
use Bubblegum::Constraints -typesof; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
29
|
|
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 'result' => ( |
21
|
|
|
|
|
|
|
is => 'rw', |
22
|
|
|
|
|
|
|
isa => typeof_object, |
23
|
|
|
|
|
|
|
required => 1 |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has 'hooks' => ( |
27
|
|
|
|
|
|
|
is => 'ro', |
28
|
|
|
|
|
|
|
isa => typeof_hashref, |
29
|
|
|
|
|
|
|
default => sub {{ before => [], during => [], after => [] }} |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has 'executable' => ( |
33
|
|
|
|
|
|
|
is => 'rw', |
34
|
|
|
|
|
|
|
isa => typeof_integer, |
35
|
|
|
|
|
|
|
default => 1 |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has 'terminated' => ( |
39
|
|
|
|
|
|
|
is => 'rw', |
40
|
|
|
|
|
|
|
isa => typeof_integer, |
41
|
|
|
|
|
|
|
default => 0 |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
2
|
|
|
2
|
0
|
4
|
method execute { |
|
2
|
|
|
|
|
3
|
|
45
|
2
|
50
|
|
|
|
24
|
return if !$self->executable; |
46
|
|
|
|
|
|
|
|
47
|
2
|
|
|
|
|
533
|
my @schedules = ( |
48
|
|
|
|
|
|
|
$self->hooks->get('before'), |
49
|
|
|
|
|
|
|
$self->hooks->get('during'), |
50
|
|
|
|
|
|
|
$self->hooks->get('after'), |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
2
|
|
|
|
|
172
|
for my $schedule (@schedules) { |
54
|
6
|
50
|
|
|
|
71
|
if ($schedule->isa_arrayref) { |
55
|
6
|
|
|
|
|
31
|
for my $task ($schedule->list) { |
56
|
6
|
50
|
|
|
|
63
|
next if !$task->isa_coderef; |
57
|
6
|
|
|
|
|
31
|
$task->call($self, @_); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
2
|
|
|
|
|
38
|
return $self->result; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
6
|
|
|
6
|
1
|
920
|
method hook { |
|
6
|
|
|
|
|
9
|
|
66
|
6
|
|
|
|
|
10
|
my $name = shift; |
67
|
6
|
|
|
|
|
8
|
my $code = shift; |
68
|
|
|
|
|
|
|
|
69
|
6
|
|
|
|
|
40
|
$name->asa_string; |
70
|
6
|
|
|
|
|
628
|
$code->asa_coderef; |
71
|
|
|
|
|
|
|
|
72
|
6
|
|
|
|
|
633
|
my $list = $self->hooks->get($name); |
73
|
|
|
|
|
|
|
|
74
|
6
|
50
|
|
|
|
236
|
unless ($list->isa_arrayref) { |
75
|
|
|
|
|
|
|
# transition hooking failure |
76
|
0
|
|
|
|
|
0
|
State::Machine::Failure::Transition::Hook->throw( |
77
|
|
|
|
|
|
|
hook_name => $name, |
78
|
|
|
|
|
|
|
transition_name => $self->name, |
79
|
|
|
|
|
|
|
transition_object => $self, |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
6
|
|
|
|
|
30
|
$list->push($code); |
84
|
6
|
|
|
|
|
42
|
return $self; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__END__ |