blib/lib/IO/Iron/IronCache/Policy.pm

filter: Statementstmt 82.1% 83 / 101 Branchbran 50.0% 4 / 8 Conditioncond 16.6% 2 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 84.6% 22 / 26 Podpod 100% 8 / 8 totaltotal 73.0% 119 / 163 SCAR 23.5
CC
9
Cov
74%
is_cache_name_alternatives
6.0
is_item_key_alternatives
6.0
__ANON__
4.6
CRAP 10.5
« blib/lib/IO/Iron/IronMQ/Message.pm ↑ Summary blib/lib/IO/Iron/Common.pm »
1 package IO::Iron::IronCache::Policy;
2  
3 ## no critic (Documentation::RequirePodAtEnd)
4 ## no critic (Documentation::RequirePodSections)
5 ## no critic (Subroutines::RequireArgUnpacking
6  
7 6 ▶use 5.010_000;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # Global creator
12 BEGIN {
13 6 ▶ use parent qw( IO::Iron::PolicyBase ); # Inheritance
Subroutine BEGIN: called CC=1 SCAR=0.0
14 }
15  
16 # Global destructor
17 ▶END {
Subroutine END: called CC=1 SCAR=0.0
18 }
19  
20  
21 # ABSTRACT: Base package (inherited) for IronCache::Client package.
22  
23 6 our $VERSION = '0.13'; # VERSION: generated by DZP::OurPkgVersion
24  
25  
26 6 ▶use Log::Any qw{$log};
Subroutine BEGIN: called CC=1 SCAR=0.0
27 6 ▶use Hash::Util 0.06 qw{lock_keys unlock_keys};
Subroutine BEGIN: called CC=1 SCAR=0.0
28 6 ▶use Carp::Assert::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 6 ▶use English '-no_match_vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
30 6 ▶use Params::Validate qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
31 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 6 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: not called CC=1 SCAR=0.0
33  
34  
35  
36 sub is_cache_name_alternatives {
37 0 ▶ my $self = shift;
Subroutine is_cache_name_alternatives: not called CC=2 SCAR=17.9
Pod documented
38 0 my %params = validate(@_, { } ); # No parameters
39 0 $log->tracef('Entering is_cache_name_alternatives(%s)', \%params);
40 my $rval = !(
41 defined $self->{'policy'}->{'definition'}->{'no_limitation'}
42 0 ▶ && $self->{'policy'}->{'definition'}->{'no_limitation'} == 1
Condition0%0/3
defined $self->{'policy'}{'definition'}{'no_limitation'} && $self->{'policy'}{'definition'}{'no_limitation'} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{'policy'}{'definition'}{'no_limitation'} && $self->{'policy'}{'definition'}{'no_limitation'} == 1
defined $self->{'policy'}{'definition'}{'no_limitation'} $self->{'policy'}{'definition'}{'no_limitation'} == 1
Truth table0%0/3
A && B
A= defined $self->{'policy'}{'definition'}{'no_limitation'}B= $self->{'policy'}{'definition'}{'no_limitation'} == 1
ABresult
0X0
100
111
43 );
44 0 $log->tracef('Exiting is_cache_name_alternatives():%d', $rval);
45 0 return $rval;
46 }
47  
48  
49 sub is_item_key_alternatives {
50 0 ▶ my $self = shift;
Subroutine is_item_key_alternatives: not called CC=2 SCAR=17.9
Pod documented
51 0 my %params = validate(@_, { } ); # No parameters
52 0 $log->tracef('Entering is_item_key_alternatives(%s)', \%params);
53 my $rval = !(
54 defined $self->{'policy'}->{'definition'}->{'no_limitation'}
55 0 ▶ && $self->{'policy'}->{'definition'}->{'no_limitation'} == 1
Condition0%0/3
defined $self->{'policy'}{'definition'}{'no_limitation'} && $self->{'policy'}{'definition'}{'no_limitation'} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{'policy'}{'definition'}{'no_limitation'} && $self->{'policy'}{'definition'}{'no_limitation'} == 1
defined $self->{'policy'}{'definition'}{'no_limitation'} $self->{'policy'}{'definition'}{'no_limitation'} == 1
Truth table0%0/3
A && B
A= defined $self->{'policy'}{'definition'}{'no_limitation'}B= $self->{'policy'}{'definition'}{'no_limitation'} == 1
ABresult
0X0
100
111
56 );
57 0 $log->tracef('Exiting is_item_key_alternatives():%d', $rval);
58 0 return $rval;
59 }
60  
61  
62 sub cache_name_alternatives {
63 3 ▶ my $self = shift;
Subroutine cache_name_alternatives: called CC=1 SCAR=0.0
Pod documented
64 3 my %params = validate(@_, { } ); # No parameters
65 3 $log->tracef('Entering cache_name_alternatives(%s)', \%params);
66  
67 3 my @alternatives = $self->alternatives( 'required_policy' => 'name' );
68  
69 3 $log->tracef('Exiting cache_name_alternatives():%s', \@alternatives);
70 3 return @alternatives;
71 }
72  
73  
74 sub item_key_alternatives {
75 0 ▶ my $self = shift;
Subroutine item_key_alternatives: not called CC=1 SCAR=6.9
Pod documented
76 0 my %params = validate(@_, { } ); # No parameters
77 0 $log->tracef('Entering item_key_alternatives(%s)', \%params);
78  
79 0 my @alternatives = $self->alternatives( 'required_policy' => 'item_key' );
80  
81 0 $log->tracef('Exiting item_key_alternatives():%s', \@alternatives);
82 0 return @alternatives;
83 }
84  
85  
86 sub is_valid_cache_name {
87 4 ▶ my $self = shift;
Subroutine is_valid_cache_name: called CC=1 SCAR=0.1
Pod documented
88 4 my %params = validate(
89 @_, {
90 'name' => { type => SCALAR, }, # cache name.
91 }
92 );
93 4 $log->tracef('Entering is_valid_cache_name(%s)', \%params);
94 4 my $validity = 1;
95 try {
96 4 ▶ $log->tracef('is_valid_cache_name:Enter try/catch.');
Subroutine __ANON__: called CC=1 SCAR=0.0
97 4 $self->validate_cache_name('name' => $params{'name'});
98 }
99 catch {
100 2 ▶ $log->tracef('is_valid_cache_name:Caught exception.');
Subroutine __ANON__: called CC=4 SCAR=15.2
101 2 ▶ croak $_ unless blessed $_ && $_->can('rethrow'); ## no critic (ControlStructures::ProhibitPostfixControls)
Branch: 1 branch
BranchTrueFalseTotal
unless $_->blessed and $_->can("rethrow") 0 2 2
Condition33%1/3
$_->blessed and $_->can("rethrow")
!ll&&!rl&&r
002
MC/DC0%0/2
$_->blessed and $_->can("rethrow")
$_->blessed $_->can("rethrow")
Truth table33%1/3
A and B
A= $_->blessedB= $_->can("rethrow")
ABresult
0X0
100
111
102 2 ▶ if ( $_->isa('IronPolicyException') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->isa("IronPolicyException")) 2 0 2
103 2 $log->tracef('Caught IronPolicyException.');
104 2 $validity = 0;
105 }
106 4 };
107 4 $log->tracef('Exiting is_valid_cache_name():%d', $validity);
108 4 return $validity;
109 }
110  
111  
112 sub validate_cache_name {
113 6 ▶ my $self = shift;
Subroutine validate_cache_name: called CC=1 SCAR=0.0
Pod documented
114 6 my %params = validate(
115 @_, {
116 'name' => { type => SCALAR, }, # cache name.
117 }
118 );
119 6 $log->tracef('Entering validate_cache_name(%s)', \%params);
120 $self->validate_with_policy(
121 'policy' => 'name',
122 6 'candidate' => $params{'name'});
123 3 $log->tracef('Exiting validate_cache_name():[NONE]');
124 3 return;
125 }
126  
127  
128 sub is_valid_item_key {
129 2 ▶ my $self = shift;
Subroutine is_valid_item_key: called CC=1 SCAR=0.1
Pod documented
130 2 my %params = validate(
131 @_, {
132 'key' => { type => SCALAR, }, # cache name.
133 }
134 );
135 2 $log->tracef('Entering is_valid_item_key(%s)', \%params);
136 2 my $validity = 1;
137 try {
138 2 ▶ $log->tracef('is_valid_item_key:Enter try/catch.');
Subroutine __ANON__: called CC=1 SCAR=0.0
139 2 $self->validate_item_key('key' => $params{'key'});
140 }
141 catch {
142 1 ▶ $log->tracef('is_valid_item_key:Caught exception.');
Subroutine __ANON__: called CC=4 SCAR=15.2
143 1 ▶ croak $_ unless blessed $_ && $_->can('rethrow'); ## no critic (ControlStructures::ProhibitPostfixControls)
Branch: 1 branch
BranchTrueFalseTotal
unless $_->blessed and $_->can("rethrow") 0 1 1
Condition33%1/3
$_->blessed and $_->can("rethrow")
!ll&&!rl&&r
001
MC/DC0%0/2
$_->blessed and $_->can("rethrow")
$_->blessed $_->can("rethrow")
Truth table33%1/3
A and B
A= $_->blessedB= $_->can("rethrow")
ABresult
0X0
100
111
144 1 ▶ if ( $_->isa('IronPolicyException') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->isa("IronPolicyException")) 1 0 1
145 1 $log->tracef('Caught IronPolicyException.');
146 1 $validity = 0;
147 }
148 2 };
149 2 $log->tracef('Exiting is_valid_item_key():%d', $validity);
150 2 return $validity;
151 }
152  
153  
154 sub validate_item_key {
155 3 ▶ my $self = shift;
Subroutine validate_item_key: called CC=1 SCAR=0.0
Pod documented
156 3 my %params = validate(
157 @_, {
158 'key' => { type => SCALAR, }, # cache name.
159 }
160 );
161 3 $log->tracef('Entering validate_item_key(%s)', \%params);
162 $self->validate_with_policy(
163 'policy' => 'item_key',
164 3 'candidate' => $params{'key'});
165 1 $log->tracef('Exiting validate_item_key():[NONE]');
166 1 return;
167 }
168  
169  
170 # INTERNAL METHODS
171 # For use in the inheriting subclass
172  
173 # This is a late binding to inherited method get_policies:
174 sub _THIS_POLICY { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines)
175 2 ▶ my $self = shift;
Subroutine _THIS_POLICY: called CC=1 SCAR=0.0
176 2 my %params = validate(
177 @_, {
178 # No parameters.
179 }
180 );
181 2 return 'cache';
182 }
183  
184 6 1;
185  
186 __END__
« blib/lib/IO/Iron/IronMQ/Message.pm ↑ Summary blib/lib/IO/Iron/Common.pm »