Conveyor/Value/Ticket/RC.pm

filter: Statementstmt 100% 12 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 17 / 17 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Conveyor/Value/Ticket/Number.pm ↑ Summary Conveyor/Value/Ticket/RC_TEST.pm »
1 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Data::Conveyor::Value::Ticket::RC;
6 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 $Data::Conveyor::Value::Ticket::RC::VERSION = '1.103130';
8 }
9 # ABSTRACT: Stage-based conveyor-belt-like ticket handling system
10 1 ▶use parent 'Data::Conveyor::Value::Enum';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 sub get_valid_values_list { our $cache_values ||= $_[0]->delegate->RC }
12  
13 sub send_notify_value_invalid {
14 my ($self, $value) = @_;
15 local $Error::Depth = $Error::Depth + 2;
16 $self->exception_container->record(
17 'Data::Conveyor::Exception::Ticket::NoSuchRC',
18 rc => $value,);
19 }
20  
21 # Apply a new rc to the value object's existing rc. When called by the payload
22 # methods this method makes sure that the resulting rc is the worst of all
23 # exception's associated rc's. That is, if there are only exceptions with
24 # RC_ERROR, the whole ticket will have RC_ERROR as its rc. But if one of those
25 # exceptions is associated with RC_INTERNAL_ERROR, the whole ticket will have
26 # RC_INTERNAL_ERROR.
27 #
28 # We use an op table for "$ticket_rc * $rc". Here, 'OK' stands for
29 # 'RC_OK', 'ERR' for 'RC_ERROR' and 'INT' for 'RC_INTERNAL_ERROR'.
30 #
31 # rhs |
32 # lhs | OK ERR INT
33 # -------+---------------------------
34 # OK | OK ERR INT
35 # ERR | ERR ERR INT
36 # INT | INT INT INT
37 #
38 # The following simple code relies on the fact that RC_* are encoded as
39 # numbers that increase with increasing severity. If that premise doesn't
40 # hold anymore, we'll probably have to implement a real ops table.
41 sub add {
42 my ($rc1, $rc2) = @_;
43 $rc1 > $rc2 ? $rc1 : $rc2;
44 }
45  
46 sub num_cmp {
47 my ($rc1, $rc2) = @_;
48 "$rc1" <=> "$rc2";
49 }
50 1;
51  
52  
53 __END__
« Conveyor/Value/Ticket/Number.pm ↑ Summary Conveyor/Value/Ticket/RC_TEST.pm »