File Coverage

blib/lib/Mojo/Cache/Role/Strict.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package Mojo::Cache::Role::Strict;
2 3     3   9760 use Mojo::Base -role;
  3         6  
  3         22  
3 3     3   1357 use Carp ();
  3         15  
  3         568  
4              
5             with 'Mojo::Cache::Role::Exists';
6              
7             our $VERSION = '0.04';
8              
9             has [qw(strict_get strict_set)] => 1;
10              
11             before get => sub {
12             Carp::confess qq{unknown key '$_[1]'} if $_[0]->strict_get and not $_[0]->exists($_[1]);
13             };
14              
15             before set => sub {
16             Carp::confess 'cannot set in strict_set mode' if $_[0]->strict_set;
17             };
18              
19             1;
20             __END__