line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: DAO request - create |
2
|
|
|
|
|
|
|
package PONAPI::DAO::Request::Create; |
3
|
|
|
|
|
|
|
|
4
|
8
|
|
|
8
|
|
48
|
use Moose; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
67
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
extends 'PONAPI::DAO::Request'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with 'PONAPI::DAO::Request::Role::HasData', |
9
|
|
|
|
|
|
|
'PONAPI::DAO::Request::Role::HasDataMethods'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub execute { |
12
|
27
|
|
|
27
|
0
|
52
|
my $self = shift; |
13
|
27
|
|
|
|
|
953
|
my $doc = $self->document; |
14
|
|
|
|
|
|
|
|
15
|
27
|
|
|
|
|
43
|
my @headers; |
16
|
27
|
100
|
|
|
|
955
|
if ( $self->is_valid ) { |
17
|
9
|
|
|
|
|
336
|
$self->repository->create( %{ $self } ); |
|
9
|
|
|
|
|
71
|
|
18
|
4
|
|
|
|
|
432
|
$doc->add_meta( |
19
|
|
|
|
|
|
|
detail => "successfully created the resource: " |
20
|
|
|
|
|
|
|
. $self->type |
21
|
|
|
|
|
|
|
. " => " |
22
|
|
|
|
|
|
|
. $self->json->encode( $self->data ) |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
4
|
50
|
|
|
|
267
|
$doc->set_status(201) unless $doc->has_status; |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
40
|
my $document = $doc->build; |
28
|
4
|
|
|
|
|
27
|
my $self_link = $document->{data}{links}{self}; |
29
|
4
|
|
33
|
|
|
57
|
$self_link //= "/$document->{data}{type}/$document->{data}{id}"; |
30
|
|
|
|
|
|
|
|
31
|
4
|
|
|
|
|
34
|
push @headers, Location => $self_link; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
22
|
|
|
|
|
121
|
return $self->response( @headers ); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
38
|
8
|
|
|
8
|
|
56059
|
no Moose; 1; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
43
|
|
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.002006 |
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 |