File Coverage

blib/lib/Shipment/Package.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package Shipment::Package;
2             $Shipment::Package::VERSION = '2.00';
3 5     5   44 use strict;
  5         8  
  5         308  
4 5     5   34 use warnings;
  5         11  
  5         208  
5              
6              
7 5     5   61 use Data::Currency;
  0            
  0            
8              
9             use Moo;
10             use MooX::Types::MooseLike::Base qw(:all);
11             use namespace::clean;
12              
13              
14             has 'id' => (
15             is => 'rw',
16             isa => Str,
17             );
18              
19              
20             has 'type' => (
21             is => 'rw',
22             isa => Str,
23             );
24              
25              
26             has 'name' => (
27             is => 'rw',
28             isa => Str,
29             );
30              
31              
32             has 'notes' => (
33             is => 'rw',
34             isa => Str,
35             );
36              
37              
38             has 'fragile' => (
39             is => 'rw',
40             isa => Bool,
41             default => 0,
42             );
43              
44              
45             has 'weight' => (
46             is => 'rw',
47             isa => Num,
48             );
49              
50              
51             has 'length' => (
52             is => 'rw',
53             isa => Num,
54             );
55              
56             has 'width' => (
57             is => 'rw',
58             isa => Num,
59             );
60              
61             has 'height' => (
62             is => 'rw',
63             isa => Num,
64             );
65              
66              
67             has 'insured_value' => (
68             is => 'rw',
69             isa => InstanceOf ['Data::Currency'],
70             default => sub { Data::Currency->new(0) },
71             );
72              
73              
74             has 'goods_value' => (
75             is => 'rw',
76             isa => InstanceOf ['Data::Currency'],
77             lazy => 1,
78             builder => 1,
79             );
80              
81             sub _build_goods_value {
82             return shift->insured_value;
83             }
84              
85              
86             has 'label' => (
87             is => 'rw',
88             isa => InstanceOf ['Shipment::Label'],
89             );
90              
91              
92             has 'tracking_id' => (
93             is => 'rw',
94             isa => Str,
95             );
96              
97              
98             has 'cost' => (
99             is => 'rw',
100             isa => InstanceOf ['Data::Currency'],
101             default => sub { Data::Currency->new(0) },
102             );
103              
104              
105             1;
106              
107             __END__
108              
109             =pod
110              
111             =encoding UTF-8
112              
113             =head1 NAME
114              
115             Shipment::Package
116              
117             =head1 VERSION
118              
119             version 2.00
120              
121             =head1 SYNOPSIS
122              
123             use Shipment::Package;
124              
125             my $package = Shipment::Package->new(
126             weight => 10,
127             length => 18,
128             width => 18,
129             height => 24,
130             );
131              
132             =head1 NAME
133              
134             Shipment::Package - a package to be shipped
135              
136             =head1 ABOUT
137              
138             This class defines a package to be shipped. It also includes attributes which
139             are set after a shipment has been created (label, cost, tracking_id)
140              
141             =head1 Class Attributes
142              
143             =head2 id
144              
145             The package type id as defined by a shipping service
146              
147             type: String
148              
149             =head2 type
150              
151             The package type as defined by a shipping service (i.e. "envelope")
152              
153             type: String
154              
155             =head2 name
156              
157             A descriptive name for the package (i.e. "12x12x12 box")
158              
159             type: String
160              
161             =head2 notes
162              
163             Notes (i.e. to describe the package contents)
164              
165             type: String
166              
167             =head2 fragile
168              
169             Whether or not the items being sent are fragile
170              
171             =head2 weight
172              
173             The weight of the package. Units are determined by the Shipment::Base class
174              
175             type: Number
176              
177             =head2 length, width, height
178              
179             The dimensions of the package. Units are determined by the Shipment::Base class
180              
181             type: Number
182              
183             =head2 insured_value
184              
185             The value of the contents to be insured
186              
187             type: Data::Currency
188              
189             =head2 goods_value
190              
191             The value of the contents
192              
193             type: Data::Currency
194              
195             =head2 label
196              
197             The shipping label. Set by a Shipment::Base class
198              
199             type: Shipment::Label
200              
201             =head2 tracking_id
202              
203             The tracking id. Set by a Shipment::Base class.
204              
205             Also can be used to define a tracking id to cancel or track.
206              
207             type: String
208              
209             =head2 cost
210              
211             The cost to ship this package. Set by a Shipment::Base class
212              
213             type: Data::Currency
214              
215             =head1 AUTHOR
216              
217             Andrew Baerg @ <andrew at pullingshots dot ca>
218              
219             http://pullingshots.ca/
220              
221             =head1 BUGS
222              
223             Please contact me directly.
224              
225             =head1 COPYRIGHT
226              
227             Copyright (C) 2010 Andrew J Baerg, All Rights Reserved
228              
229             =head1 NO WARRANTY
230              
231             Absolutely, positively NO WARRANTY, neither express or implied, is
232             offered with this software. You use this software at your own risk. In
233             case of loss, no person or entity owes you anything whatsoever. You
234             have been warned.
235              
236             =head1 LICENSE
237              
238             This program is free software; you can redistribute it and/or modify it
239             under the same terms as Perl itself.
240              
241             =head1 AUTHOR
242              
243             Andrew Baerg <baergaj@cpan.org>
244              
245             =head1 COPYRIGHT AND LICENSE
246              
247             This software is copyright (c) 2013 by Andrew Baerg.
248              
249             This is free software; you can redistribute it and/or modify it under
250             the same terms as the Perl 5 programming language system itself.
251              
252             =cut