Filename | /home/mickey/git_tree/PONAPI/Server/lib/PONAPI/DAO/Request/Create.pm |
Statements | Executed 8 statements in 240µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 18µs | 3.08ms | BEGIN@4 | PONAPI::DAO::Request::Create::
1 | 1 | 1 | 8µs | 93µs | BEGIN@38 | PONAPI::DAO::Request::Create::
0 | 0 | 0 | 0s | 0s | execute | PONAPI::DAO::Request::Create::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # ABSTRACT: DAO request - create | ||||
2 | package PONAPI::DAO::Request::Create; | ||||
3 | |||||
4 | 2 | 186µs | 2 | 6.14ms | # spent 3.08ms (18µs+3.06) within PONAPI::DAO::Request::Create::BEGIN@4 which was called:
# once (18µs+3.06ms) by PONAPI::DAO::BEGIN@10 at line 4 # spent 3.08ms making 1 call to PONAPI::DAO::Request::Create::BEGIN@4
# spent 3.06ms making 1 call to Moose::import |
5 | |||||
6 | 1 | 1µs | 1 | 588µs | extends 'PONAPI::DAO::Request'; # spent 588µs making 1 call to Moose::extends |
7 | |||||
8 | 1 | 2µs | 1 | 16.6ms | with 'PONAPI::DAO::Request::Role::HasData', # spent 16.6ms making 1 call to Moose::with |
9 | 'PONAPI::DAO::Request::Role::HasDataMethods'; | ||||
10 | |||||
11 | sub execute { | ||||
12 | my $self = shift; | ||||
13 | my $doc = $self->document; | ||||
14 | |||||
15 | my @headers; | ||||
16 | if ( $self->is_valid ) { | ||||
17 | $self->repository->create( %{ $self } ); | ||||
18 | $doc->add_meta( | ||||
19 | detail => "successfully created the resource: " | ||||
20 | . $self->type | ||||
21 | . " => " | ||||
22 | . $self->json->encode( $self->data ) | ||||
23 | ); | ||||
24 | |||||
25 | $doc->set_status(201) unless $doc->has_status; | ||||
26 | |||||
27 | my $document = $doc->build; | ||||
28 | my $self_link = $document->{data}{links}{self}; | ||||
29 | $self_link //= "/$document->{data}{type}/$document->{data}{id}"; | ||||
30 | |||||
31 | push @headers, Location => $self_link; | ||||
32 | } | ||||
33 | |||||
34 | return $self->response( @headers ); | ||||
35 | } | ||||
36 | |||||
37 | 1 | 5µs | 2 | 10.1ms | __PACKAGE__->meta->make_immutable; # spent 10.1ms making 1 call to Class::MOP::Class::make_immutable
# spent 13µs making 1 call to PONAPI::DAO::Request::Create::meta |
38 | 3 | 45µs | 2 | 178µs | # spent 93µs (8+85) within PONAPI::DAO::Request::Create::BEGIN@38 which was called:
# once (8µs+85µs) by PONAPI::DAO::BEGIN@10 at line 38 # spent 93µs making 1 call to PONAPI::DAO::Request::Create::BEGIN@38
# spent 85µs making 1 call to Moose::unimport |
39 | |||||
40 | __END__ |