File Coverage

blib/lib/XML/NewsML_G2/News_Message.pm
Criterion Covered Total %
statement 8 8 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 11 11 100.0


line stmt bran cond sub pod time code
1             package XML::NewsML_G2::News_Message;
2              
3 18     18   138 use Moose;
  18         48  
  18         152  
4 18     18   118070 use namespace::autoclean;
  18         45  
  18         169  
5              
6             # header elements
7             has 'sent',
8             isa => 'DateTime',
9             is => 'ro',
10             lazy => 1,
11             builder => '_build_sent';
12              
13             has 'destination',
14             isa => 'ArrayRef[XML::NewsML_G2::Destination]',
15             is => 'ro',
16             default => sub { [] },
17             traits => ['Array'],
18             handles => { add_destination => 'push' };
19              
20             #news/package items
21             has 'items',
22             isa => 'ArrayRef[XML::NewsML_G2::AnyItem]',
23             is => 'rw',
24             default => sub { [] },
25             traits => ['Array'],
26             handles => { add_item => 'push' };
27              
28             has 'timezone', is => 'ro', isa => 'Str', default => 'local';
29              
30             sub _build_sent {
31 3     3   9 my ($self) = @_;
32 3         86 return DateTime->now( time_zone => $self->timezone );
33             }
34              
35             __PACKAGE__->meta->make_immutable;
36              
37             1;
38             __END__
39              
40             =head1 NAME
41              
42             XML::NewsML_G2::News_Message - a container that can hold multiple News
43             or Package Items
44              
45             =for test_synopsis
46             my (%text_params, %pic_params);
47              
48             =head1 SYNOPSIS
49              
50             my $nm = XML::NewsML_G2::News_Message->new();
51             my $ni_text = XML::NewsML_G2::News_Item_Text->new(%text_params);
52             my $ni_picture = XML::NewsML_G2::News_Item_Picture->new(%pic_params);
53             $nm->add_item($ni_text);
54             $nm->add_item($ni_picture);
55              
56             =head1 ATTRIBUTES
57              
58             =over 4
59              
60             =item sent
61              
62             Timestamp generated automatically
63              
64             =item destination
65              
66             Intended target for news message
67              
68             =item items
69              
70             A collection of news and/or package items
71              
72             =back
73              
74             =head1 AUTHOR
75              
76             Stefan Hrdlicka C<< <stefan.hrdlicka@apa.at> >>
77              
78             =head1 LICENCE AND COPYRIGHT
79              
80             Copyright (c) 2013, APA-IT. All rights reserved.
81              
82             See L<XML::NewsML_G2> for the license.