aggregator/Drivers.pm

filter: Statementstmt 94.7% 18 / 19 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 33.3% 1 / 3 totaltotal 83.8% 26 / 31 CC 3 SCAR 6.4
CC
3
Cov
87%
add
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« aggregator.pm ↑ Summary
1 package CGI::Session::Driver::aggregator::Drivers;
2  
3 # $Id$
4  
5 =head1 NAME
6  
7 CGI::Session::Driver::aggregator::Drivers - Drivers container for CGI::Session::Driver::aggregator
8  
9 =cut
10  
11 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶sub new { bless { drivers => [] }, shift }
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
15  
16 =head1 METHODS
17  
18 =cut
19  
20 =head2 add($driver_name, $driver_arguments)
21  
22 Adding a driver with extra arguments. driver_arguments will be used to instanctiate the driver. The driver must be an instance of CGI::Session::Driver.
23  
24 $drivers = CGI::Session::Driver::aggregator::Drivers->new;
25 $drivers->add('file', { Directory => '/tmp' });
26 $drivers->add('mysql', { Handle => $dbh });
27  
28 NOTE: session data is read from drivers in the added order. In above example, reading from 'file' first, and then from 'mysql' (only when cannot read from 'file'). On the other hand, When writing session data, the order is 'mysql' -> 'file'.
29  
30 =cut
31 4 ▶sub add {
Subroutine add: called CC=3 SCAR=11.3
Pod documented
32 4 my ($self, $name, $args) = @_;
33 4 $name = lc $name;
34  
35 4 my $package = "CGI::Session::Driver::$name";
36 4 ▶ if (!exists $INC{$package}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $INC{$package}) 4 0 4
37 4 eval "require $package";
38 4 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 4 4
39 0 croak "Failed to load a driver: $@";
40 }
41 }
42  
43 4 push @{ $self->{drivers} }, { package => $package, args => $args };
44 }
45  
46 8 ▶sub drivers { @{ shift->{drivers} } }
Subroutine drivers: called CC=1 SCAR=0.0
Pod undocumented
47  
48 2 1;
« aggregator.pm ↑ Summary