lib/Rapi/Blog/DB/Component/SafeResult.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 58 CC 4 SCAR 16.4
CC
4
Cov
0%
_caller_is_template
12.0
_caller_not_allowed
6.0
insert
2.0
CRAP 5.2
1 package Rapi::Blog::DB::Component::SafeResult;
2  
3 use strict;
4 use warnings;
5
6 use parent 'DBIx::Class::Core';
7 use RapidApp::Util ':all';
8  
9 our $ALLOW = 0;
10  
11 sub _caller_not_allowed {
12 my $self = shift;
13 return 0 if ($ALLOW);
14 return $self->_caller_is_template;
15 }
16  
17 sub _caller_is_template {
18 if(my $c = RapidApp->active_request_context) {
19 return 1 if($c->controller('RapidApp::Template')->Access->currently_viewing_template);
20 }
21 return 0;
22 }
23  
24 sub insert {
25 my $self = shift;
26 $self->_caller_not_allowed and die "INSERT denied";
27 $self->next::method(@_)
28 }
29  
30 sub update {
31 my $self = shift;
32 $self->_caller_not_allowed and die "UPDATE denied";
33 $self->next::method(@_)
34 }
35  
36 sub delete {
37 my $self = shift;
38 $self->_caller_not_allowed and die "DELETE denied";
39 $self->next::method(@_)
40 }
41  
42  
43 1;