PONAPI/DAO/Request/Create.pm

filter: Statementstmt 100% 23 / 23 Branchbran 75.0% 3 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 3 / 3 Podpod 0.0% 0 / 1 totaltotal 88.2% 30 / 34 CC 4 SCAR 11.0
CC
4
Cov
93%
execute
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« PONAPI/DAO/Request/Role/UpdateLike.pm ↑ Summary PONAPI/DAO/Request/Role/HasInclude.pm »
1 # ABSTRACT: DAO request - create
2 package PONAPI::DAO::Request::Create;
3  
4 8 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 extends 'PONAPI::DAO::Request';
7  
8 8 with 'PONAPI::DAO::Request::Role::HasData',
9 'PONAPI::DAO::Request::Role::HasDataMethods';
10  
11 sub execute {
12 27 ▶ my $self = shift;
Subroutine execute: called CC=4 SCAR=13.9
Pod undocumented
13 27 my $doc = $self->document;
14  
15 27 my @headers;
16 27 ▶ if ( $self->is_valid ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_valid) 9 18 27
17 9 $self->repository->create( %{ $self } );
18 4 $doc->add_meta(
19 detail => "successfully created the resource: "
20 . $self->type
21 . " => "
22 . $self->json->encode( $self->data )
23 );
24  
25 4 ▶ $doc->set_status(201) unless $doc->has_status;
Branch: 1 branch
BranchTrueFalseTotal
unless $doc->has_status 4 0 4
26  
27 4 my $document = $doc->build;
28 4 my $self_link = $document->{data}{links}{self};
29 4 ▶ $self_link //= "/$document->{data}{type}/$document->{data}{id}";
Condition50%1/2
$self_link //= qq[/$document->{"data"}{"type"}/$document->{"data"}{"id"}]
l!l
04
MC/DC0%0/1
$self_link //= qq[/$document->{"data"}{"type"}/$document->{"data"}{"id"}]
$self_link
Truth table50%1/2
A
A= $self_link
Aresult
11
00
30  
31 4 push @headers, Location => $self_link;
32 }
33  
34 22 return $self->response( @headers );
35 }
36  
37 8 __PACKAGE__->meta->make_immutable;
38 8 ▶no Moose; 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
39  
40 __END__
41  
42 =pod
43  
44 =encoding UTF-8
45  
46 =head1 NAME
47  
48 PONAPI::DAO::Request::Create - DAO request - create
49  
50 =head1 VERSION
51  
52 version 0.002012
53  
54 =head1 AUTHORS
55  
56 =over 4
57  
58 =item *
59  
60 Mickey Nasriachi <mickey@cpan.org>
61  
62 =item *
63  
64 Stevan Little <stevan@cpan.org>
65  
66 =item *
67  
68 Brian Fraser <hugmeir@cpan.org>
69  
70 =back
71  
72 =head1 COPYRIGHT AND LICENSE
73  
74 This software is copyright (c) 2016 by Mickey Nasriachi, Stevan Little, Brian Fraser.
75  
76 This is free software; you can redistribute it and/or modify it under
77 the same terms as the Perl 5 programming language system itself.
78  
79 =cut
« PONAPI/DAO/Request/Role/UpdateLike.pm ↑ Summary PONAPI/DAO/Request/Role/HasInclude.pm »