MtPolicyd/SessionCache.pm

filter: Statementstmt 33.3% 10 / 30 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 2 / 4 Podpod 0.0% 0 / 1 totaltotal 29.2% 12 / 41 CC 4 SCAR 24.8
CC
4
Cov
28%
load_config
20.0
__ANON__
2.0
BEGIN
1.0
CRAP 12.0
« MtPolicyd/SessionCache/Redis.pm ↑ Summary MtPolicyd/Client.pm »
1 package Mail::MtPolicyd::SessionCache;
2  
3 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 our $VERSION = '2.01'; # VERSION
6 # ABSTRACT: class for handling session cache
7  
8 2 ▶use Mail::MtPolicyd::SessionCache::None;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 has 'server' => (
11 is => 'ro', isa => 'Net::Server', required => 1,
12 handles => {
13 'log' => 'log',
14 }
15 );
16  
17 has 'cache' => (
18 is => 'rw', isa => 'Mail::MtPolicyd::SessionCache::Base',
19 lazy => 1,
20 0 ▶ default => sub { Mail::MtPolicyd::SessionCache::None->new },
Subroutine __ANON__: not called CC=1 SCAR=6.9
21 2 handles => [
22 'retrieve_session', 'store_session', 'shutdown',
23 ],
24 );
25  
26 sub load_config {
27 0 ▶ my ( $self, $config ) = @_;
Subroutine load_config: not called CC=4 SCAR=30.0
Pod undocumented
28 0 ▶ if( ! defined $config->{'module'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $config->{"module"}) 0 0 0
29 0 die('no module defined for SessionCache!');
30 }
31 0 my $module = $config->{'module'};
32 0 my $class = 'Mail::MtPolicyd::SessionCache::'.$module;
33 0 my $cache;
34  
35 0 $self->log(1, 'loading SessionCache '.$module);
36 0 my $code = "require ".$class.";";
37 0 eval $code; ## no critic (ProhibitStringyEval)
38 0 ▶ if($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
39 0 die('could not load SessionCache '.$module.': '.$@);
40 }
41  
42 0 $self->log(1, 'initializing SessionCache '.$module);
43 0 eval {
44 0 $cache = $class->new(
45 %$config,
46 );
47 0 $cache->init();
48 };
49 0 ▶ if($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
50 0 die('could not initialize SessionCache: '.$@);
51 }
52 0 $self->cache( $cache );
53 0 return;
54 }
55  
56 2 1;
57  
58 __END__
59  
60 =pod
61  
62 =encoding UTF-8
63  
64 =head1 NAME
65  
66 Mail::MtPolicyd::SessionCache - class for handling session cache
67  
68 =head1 VERSION
69  
70 version 2.01
71  
72 =head1 AUTHOR
73  
74 Markus Benning <ich@markusbenning.de>
75  
76 =head1 COPYRIGHT AND LICENSE
77  
78 This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>.
79  
80 This is free software, licensed under:
81  
82 The GNU General Public License, Version 2, June 1991
83  
84 =cut
« MtPolicyd/SessionCache/Redis.pm ↑ Summary MtPolicyd/Client.pm »