File Coverage

blib/lib/Business/UPS/Tracking/Element/Code.pm
Criterion Covered Total %
statement 14 22 63.6
branch 0 2 0.0
condition n/a
subroutine 5 7 71.4
pod 0 1 0.0
total 19 32 59.3


line stmt bran cond sub pod time code
1             # ============================================================================
2             package Business::UPS::Tracking::Element::Code;
3             # ============================================================================
4 1     1   5 use utf8;
  1         1  
  1         4  
5 1     1   33 use 5.0100;
  1         2  
6              
7 1     1   4 use Moose;
  1         1  
  1         4  
8              
9 1     1   4149 use Business::UPS::Tracking::Utils;
  1         1  
  1         145  
10              
11             =encoding utf8
12              
13             =head1 NAME
14              
15             Business::UPS::Tracking::Element::Code - Generic container for parameters
16            
17             =head1 DESCRIPTION
18              
19             This is a generic container class used to store information constisting
20             of a code and a description
21              
22             =head1 ACCESSORS
23              
24             =head2 xml
25              
26             Original L<XML::LibXML::Node> node.
27              
28             =head2 meta
29              
30             Moose meta method
31              
32             =head2 Code
33              
34             Alphanumeric code
35              
36             =head2 Description
37              
38             Description string
39              
40             =cut
41              
42             has 'xml' => (
43             is => 'rw',
44             isa => 'XML::LibXML::Node',
45             required => 1,
46             trigger => \&_build_code,
47             );
48             has 'Code' => (
49             is => 'rw',
50             isa => 'Str',
51             );
52             has 'Description' => (
53             is => 'rw',
54             isa => 'Str',
55             );
56              
57             sub _build_code {
58 0     0     my ( $self, $xml ) = @_;
59              
60 0           $self->Code($xml->findvalue('Code'));
61 0           $self->Description($xml->findvalue('Description'));
62              
63 0           return;
64             }
65              
66             sub serialize {
67 0     0 0   my ($self) = @_;
68            
69 0 0         if ($self->Description) {
70 0           return $self->Description.' ('.$self->Code.')';
71             } else {
72 0           return $self->Code;
73             }
74            
75             }
76              
77             =head1 METHODS
78              
79             =head2 printall
80              
81             Returns the serialized object content
82              
83             =head2 meta
84              
85             Moose meta method
86              
87             =cut
88              
89             __PACKAGE__->meta->make_immutable;
90 1     1   4 no Moose;
  1         1  
  1         5  
91             1;