Document/Builder/Links.pm

filter: Statementstmt 100% 23 / 23 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 3 totaltotal 91.1% 31 / 34 CC 4 SCAR 6.4
CC
4
Cov
100%
build
3.0
add_links
2.0
BEGIN
1.0
CRAP 1.9
« Tools.pm ↑ Summary Document/Builder/Resource/Identifier.pm »
1 # ABSTRACT: document builder - links
2 package PONAPI::Document::Builder::Links;
3  
4 26 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 26 with 'PONAPI::Document::Builder',
7 'PONAPI::Document::Builder::Role::HasMeta';
8  
9 has _links => (
10 init_arg => undef,
11 traits => [ 'Hash' ],
12 is => 'ro',
13 isa => 'HashRef',
14 lazy => 1,
15 23 ▶ default => sub { +{} },
Subroutine __ANON__: called CC=1 SCAR=0.0
16 26 handles => {
17 'has_links' => 'count',
18 'has_link' => 'exists',
19 'get_link' => 'get',
20 # private ...
21 '_add_link' => 'set',
22 '_keys_links' => 'keys',
23 }
24 );
25  
26 sub add_link {
27 40 ▶ my ( $self, $rel, $url ) = @_;
Subroutine add_link: called CC=1 SCAR=0.0
Pod undocumented
28 40 $self->_add_link( $rel => $url );
29 40 return $self;
30 }
31  
32 sub add_links {
33 18 ▶ my ( $self, %links ) = @_;
Subroutine add_links: called CC=2 SCAR=6.9
Pod undocumented
34 18 $self->add_link( $_, $links{ $_ } ) foreach keys %links;
35 18 return $self;
36 }
37  
38 sub build {
39 24 ▶ my $self = $_[0];
Subroutine build: called CC=3 SCAR=11.0
Pod undocumented
40 24 my $result = {};
41  
42 24 foreach my $key ( $self->_keys_links ) {
43 40 $result->{ $key } = $self->get_link( $key );
44 }
45  
46 24 ▶ $result->{meta} = $self->_meta if $self->has_meta;
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_meta 1 23 24
47  
48 24 return $result;
49 }
50  
51 26 __PACKAGE__->meta->make_immutable;
52 26 ▶no Moose; 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
53  
54 __END__
55  
56 =pod
57  
58 =encoding UTF-8
59  
60 =head1 NAME
61  
62 PONAPI::Document::Builder::Links - document builder - links
63  
64 =head1 VERSION
65  
66 version 0.001001
67  
68 =head1 AUTHORS
69  
70 =over 4
71  
72 =item *
73  
74 Mickey Nasriachi <mickey@cpan.org>
75  
76 =item *
77  
78 Stevan Little <stevan@cpan.org>
79  
80 =item *
81  
82 Brian Fraser <hugmeir@cpan.org>
83  
84 =back
85  
86 =head1 COPYRIGHT AND LICENSE
87  
88 This software is copyright (c) 2016 by Mickey Nasriachi, Stevan Little, Brian Fraser.
89  
90 This is free software; you can redistribute it and/or modify it under
91 the same terms as the Perl 5 programming language system itself.
92  
93 =cut
« Tools.pm ↑ Summary Document/Builder/Resource/Identifier.pm »