| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Error::ROP::Imp; |
|
2
|
5
|
|
|
5
|
|
1546
|
use Moose; |
|
|
5
|
|
|
|
|
1983566
|
|
|
|
5
|
|
|
|
|
39
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
has value => (is => 'ro', required => 0, default => undef); |
|
5
|
|
|
|
|
|
|
has failure => (is => 'ro', required => 0, default => ''); |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub is_valid { |
|
8
|
46
|
|
|
46
|
0
|
1228
|
return shift->failure eq ''; |
|
9
|
|
|
|
|
|
|
} |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub _then_hash { |
|
12
|
13
|
|
|
13
|
|
32
|
my ($self, @then_clauses) = @_; |
|
13
|
13
|
|
|
|
|
20
|
my $either = $self; |
|
14
|
|
|
|
|
|
|
|
|
15
|
13
|
|
|
|
|
34
|
my $length = @then_clauses / 2; |
|
16
|
13
|
|
|
|
|
46
|
for(my $i = 0; $i < $length; $i++) { |
|
17
|
15
|
|
|
|
|
32
|
my $err = $then_clauses[2 * $i]; |
|
18
|
15
|
|
|
|
|
21
|
my $fn = $then_clauses[2 * $i + 1]; |
|
19
|
15
|
100
|
|
|
|
31
|
if ($either->is_valid) { |
|
20
|
12
|
|
|
|
|
264
|
local $_ = $either->value; |
|
21
|
12
|
|
|
|
|
18
|
my $res = eval { |
|
22
|
12
|
|
|
|
|
29
|
$fn->($_); |
|
23
|
|
|
|
|
|
|
}; |
|
24
|
12
|
100
|
|
|
|
73
|
if ($@) { |
|
25
|
3
|
100
|
100
|
|
|
13
|
my $msg = length $err > 0 && $err ne 'undef' ? $err : $@; |
|
26
|
3
|
|
|
|
|
64
|
return Error::ROP::Imp->new(failure => $msg); |
|
27
|
|
|
|
|
|
|
} |
|
28
|
9
|
|
|
|
|
196
|
$either = Error::ROP::Imp->new(value => $res); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
10
|
|
|
|
|
65
|
return $either; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _then_list { |
|
36
|
7
|
|
|
7
|
|
14
|
my ($self, @then_clauses) = @_; |
|
37
|
7
|
|
|
|
|
10
|
my $either = $self; |
|
38
|
|
|
|
|
|
|
|
|
39
|
7
|
|
|
|
|
11
|
my $length = @then_clauses; |
|
40
|
7
|
|
|
|
|
22
|
for(my $i = 0; $i < $length; $i++) { |
|
41
|
7
|
|
|
|
|
14
|
my $fn = $then_clauses[$i]; |
|
42
|
7
|
100
|
|
|
|
22
|
if ($either->is_valid) { |
|
43
|
3
|
|
|
|
|
78
|
local $_ = $either->value; |
|
44
|
3
|
|
|
|
|
6
|
my $res = eval { |
|
45
|
3
|
|
|
|
|
12
|
$fn->($_); |
|
46
|
|
|
|
|
|
|
}; |
|
47
|
3
|
100
|
|
|
|
25
|
if ($@) { |
|
48
|
2
|
|
|
|
|
39
|
return Error::ROP::Imp->new(failure => $@); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
1
|
|
|
|
|
25
|
$either = Error::ROP::Imp->new(value => $res); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
5
|
|
|
|
|
21
|
return $either; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _wrap_call_with_dollar { |
|
58
|
0
|
|
|
0
|
|
0
|
my $either = shift; |
|
59
|
0
|
|
|
|
|
0
|
my $fn = shift; |
|
60
|
0
|
0
|
|
|
|
0
|
if ($either->is_valid) { |
|
61
|
0
|
|
|
|
|
0
|
local $_ = $either->value; |
|
62
|
0
|
|
|
|
|
0
|
my $res = eval { |
|
63
|
0
|
|
|
|
|
0
|
$fn->($_); |
|
64
|
|
|
|
|
|
|
}; |
|
65
|
0
|
0
|
|
|
|
0
|
if ($@) { |
|
66
|
0
|
|
|
|
|
0
|
return Error::ROP::Imp->new(failure => $@); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
0
|
|
|
|
|
0
|
$either = Error::ROP::Imp->new(value => $res); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub then { |
|
73
|
20
|
|
|
20
|
0
|
129
|
my ($self, @then_clauses) = @_; |
|
74
|
|
|
|
|
|
|
|
|
75
|
20
|
100
|
|
|
|
47
|
if((scalar @then_clauses) % 2 == 0) { |
|
76
|
13
|
|
|
|
|
31
|
$self->_then_hash(@then_clauses); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
else { |
|
79
|
7
|
|
|
|
|
18
|
$self->_then_list(@then_clauses); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
84
|
|
|
|
|
|
|
1; |