File Coverage

lib/CatalystX/Eta/Controller/AutoObject.pm
Criterion Covered Total %
statement 14 14 100.0
branch 4 6 66.6
condition 1 2 50.0
subroutine 2 2 100.0
pod n/a
total 21 24 87.5


line stmt bran cond sub pod time code
1             package CatalystX::Eta::Controller::AutoObject;
2              
3 2     2   1256 use Moose::Role;
  2         5  
  2         12  
4             requires 'object';
5              
6             around object => \&AutoObject_around_object;
7              
8             sub AutoObject_around_object {
9 7     7   76015 my $orig = shift;
10 7         18 my $self = shift;
11 7         32 my $config = $self->config;
12              
13 7         435 my ( $c, $id ) = @_;
14              
15 7 50       32 my $id_can_de_negative = $self->config->{id_can_de_negative} ? '-?' : '';
16 7   50     403 my $primary_column = $self->config->{primary_key_column} || 'id';
17              
18 7 50       474 $self->status_bad_request( $c, message => 'invalid.int' ), $c->detach
19             unless $id =~ /^$id_can_de_negative[0-9]+$/;
20              
21 7         32 $c->stash->{object} = $c->stash->{collection}->search( { "me.$primary_column" => $id } );
22 7         3588 $c->stash->{ $config->{object_key} } = $c->stash->{object}->next;
23              
24 7 100       14764 $c->detach('/error_404') unless defined $c->stash->{ $config->{object_key} };
25              
26 6         406 $self->$orig(@_);
27             }
28              
29             1;