Conveyor/Storage.pm

filter: Statementstmt 42.5% 20 / 47 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 7 / 14 Podpod 100% 7 / 7 totaltotal 44.1% 34 / 77 CC 4 SCAR 11.0
CC
4
Cov
37%
ticket_store
6.0
ticket_serialized_payload
6.0
ticket_deserialized_payload
6.0
CRAP 3.0
« Conveyor/YAML/Active/Payload/Item.pm ↑ Summary Conveyor/Ticket/Payload/Common.pm »
1 7 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Data::Conveyor::Storage;
6 7 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 7 $Data::Conveyor::Storage::VERSION = '1.103130';
8 }
9 # ABSTRACT: Stage-based conveyor-belt-like ticket handling system
10  
11 7 ▶use Error::Hierarchy::Util 'assert_defined';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 7 ▶use Class::Scaffold::Exception::Util 'assert_object_type';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 7 ▶use parent 'Class::Scaffold::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 7 __PACKAGE__->mk_abstract_accessors(
15 qw(
16 ticket_update ticket_insert get_ticket_shift_data
17 )
18 );
19  
20 # Within Data-Conveyor, rollback_mode isn't taken from the superclass'
21 # property of the same name, but we ask the delegate.
22 # Class::Scaffold::App::Test will set the rollback_mode on the Environment
23 # (which is the delegate), for example. Just be sure to place
24 # Data::Conveyor::Storage first in multiple inheritance, e.g., when inheriting
25 # both from Data::Conveyor::Storage and Data::Storage::*
26 0 ▶sub rollback_mode { $_[0]->delegate->rollback_mode }
Subroutine rollback_mode: not called CC=1 SCAR=6.9
Pod documented
27 0 ▶sub set_rollback_mode { $_[0]->delegate->set_rollback_mode }
Subroutine set_rollback_mode: not called CC=1 SCAR=6.9
Pod documented
28 0 ▶sub clear_rollback_mode { $_[0]->delegate->clear_rollback_mode }
Subroutine clear_rollback_mode: not called CC=1 SCAR=6.9
Pod documented
29  
30 0 ▶sub ticket_store {
Subroutine ticket_store: not called CC=2 SCAR=17.9
Pod documented
31 0 my ($self, $ticket) = @_;
32 0 $ticket->assert_ticket_no;
33 0 ▶ if ($self->ticket_exists($ticket)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->ticket_exists($ticket)) { } 0 0 0
34 0 $self->ticket_update($ticket);
35 } else {
36 0 $self->ticket_insert($ticket);
37 }
38 }
39  
40 0 ▶sub ticket_serialized_payload {
Subroutine ticket_serialized_payload: not called CC=2 SCAR=17.9
Pod documented
41 0 my ($self, $payload) = @_;
42 0 assert_object_type $payload, 'ticket_payload';
43 0 $payload->version($self->delegate->PAYLOAD_VERSION);
44  
45 # Serialize the ticket payload using Storable. The serialized version is
46 # stored in the dem_payload table. We need to enable the serialization of
47 # code references.
48 0 require Storable;
49 0 $Storable::Deparse = 1;
50 0 $payload = Storable::nfreeze($payload);
51  
52 # compression
53 0 require Compress::Zlib;
54 0 ▶ Compress::Zlib::compress($payload)
Branch: 1 branch
BranchTrueFalseTotal
Compress::Zlib::compress($payload) or "Error::Hierarchy::Internal::CustomMessage"->throw("custom_message", "zlib compress() failure") 0 0 0
55 || throw Error::Hierarchy::Internal::CustomMessage(
56 custom_message => 'zlib compress() failure');
57 }
58  
59 0 ▶sub ticket_deserialized_payload {
Subroutine ticket_deserialized_payload: not called CC=2 SCAR=17.9
Pod documented
60 0 my ($self, $payload) = @_;
61 0 assert_defined $payload, 'called without defind serialized payload.';
62  
63 # compression
64 0 require Compress::Zlib;
65 0 ▶ $payload = Compress::Zlib::uncompress($payload)
Condition0%0/3
Compress::Zlib::uncompress($payload) || 'Error::Hierarchy::Internal::CustomMessage'->throw('custom_message', 'zlib uncompress() failure')
l!l&&r!l&&!r
000
MC/DC0%0/2
Compress::Zlib::uncompress($payload) || 'Error::Hierarchy::Internal::CustomMessage'->throw('custom_message', 'zlib uncompress() failure')
Compress::Zlib::uncompress($payload) 'Error::Hierarchy::Internal::CustomMessage'->throw('custom_message', 'zlib uncompress() failure')
Truth table0%0/3
A || B
A= Compress::Zlib::uncompress($payload)B= 'Error::Hierarchy::Internal::CustomMessage'->throw('custom_message', 'zlib uncompress() failure')
ABresult
1X1
011
000
66 || throw Error::Hierarchy::Internal::CustomMessage(
67 custom_message => 'zlib uncompress() failure');
68  
69 # deserialize the ticket payload using Storable if it exists.
70 # we need to enable the deserialization of code references.
71 0 require Storable;
72 0 $Storable::Eval = 1;
73 0 $payload = Storable::thaw($payload);
74 0 $payload->upgrade;
75 0 $payload;
76 }
77  
78 0 ▶sub ticket_handle_exception {
Subroutine ticket_handle_exception: not called CC=1 SCAR=6.9
Pod documented
79 0 my ($self, $E) = @_;
80 0 throw $E;
81 }
82 7 1;
83  
84  
85 __END__
« Conveyor/YAML/Active/Payload/Item.pm ↑ Summary Conveyor/Ticket/Payload/Common.pm »