| 1 | package HTTP::Session::Store::DBM; | ||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 2 | ▶ | use base qw/Class::Accessor::Fast/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 2 | ▶ | use Fcntl; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 2 | ▶ | use Storable; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 2 | ▶ | use Module::Runtime (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 2 | __PACKAGE__->mk_ro_accessors(qw/file dbm_class/); | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 4 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.7
Pod
documented
| |||||||||||||||||||||
| 12 | 4 | my $class = shift; | |||||||||||||||||||
| 13 | 0 | ▶ | my %args = ref($_[0]) ? %{$_[0]} : @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 14 | # check required parameters | ||||||||||||||||||||
| 15 | 4 | for (qw/file/) { | |||||||||||||||||||
| 16 | 4 | ▶ | Carp::croak "missing parameter $_" unless $args{$_}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 17 | } | ||||||||||||||||||||
| 18 | # set default values | ||||||||||||||||||||
| 19 | 4 | ▶ | $args{dbm_class} ||= 'SDBM_File'; | ||||||||||||||||||
|
Condition100%2/2
$args{"dbm_class"} ||= "SDBM_File"
MC/DC100%1/1
$args{"dbm_class"} ||= "SDBM_File"
$args{"dbm_class"}
Truth table100%2/2
A
A= $args{"dbm_class"}
| |||||||||||||||||||||
| 20 | 4 | bless {%args}, $class; | |||||||||||||||||||
| 21 | } | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 6 | ▶ | sub dbm { | ||||||||||||||||||
|
Subroutine
dbm: called CC=4 SCAR=14.3
Pod
undocumented
| |||||||||||||||||||||
| 24 | 6 | my $self = shift; | |||||||||||||||||||
| 25 | 6 | ▶ | $self->{dbm} ||= do { | ||||||||||||||||||
|
Condition66%2/3
$self->{"dbm"} ||= do {
my %hash;
&Module::Runtime::require_module(scalar $self->dbm_class) or die $@;
tie %hash, $self->dbm_class, $self->file, 66, 384 or die qq[Cannot open dbm file for session: $self->{"dbm_class"}, $self->{"file"}];
\%hash
}
MC/DC0%0/2
$self->{"dbm"} ||= do {
my %hash;
&Module::Runtime::require_module(scalar $self->dbm_class) or die $@;
tie %hash, $self->dbm_class, $self->file, 66, 384 or die qq[Cannot open dbm file for session: $self->{"dbm_class"}, $self->{"file"}];
\%hash
}
$self->{"dbm"}
do {
my %hash;
&Module::Runtime::require_module(scalar $self->dbm_class) or die $@;
tie %hash, $self->dbm_class, $self->file, 66, 384 or die qq[Cannot open dbm file for session: $self->{"dbm_class"}, $self->{"file"}];
\%hash
}
Truth table66%2/3
A ||= B
A= $self->{"dbm"}B= do {
my %hash;
&Module::Runtime::require_module(scalar $self->dbm_class) or die $@;
tie %hash, $self->dbm_class, $self->file, 66, 384 or die qq[Cannot open dbm file for session: $self->{"dbm_class"}, $self->{"file"}];
\%hash
}
| |||||||||||||||||||||
| 26 | 4 | my %hash; | |||||||||||||||||||
| 27 | 4 | ▶ | Module::Runtime::require_module($self->dbm_class) or die $@; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 28 | 4 | ▶ | tie %hash, $self->dbm_class, $self->file, O_CREAT | O_RDWR, oct("600") or die "Cannot open dbm file for session: $self->{dbm_class}, $self->{file}"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | 4 | \%hash; | |||||||||||||||||||
| 30 | }; | ||||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 4 | ▶ | sub select { | ||||||||||||||||||
|
Subroutine
select: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 34 | 4 | my ( $self, $key ) = @_; | |||||||||||||||||||
| 35 | 4 | Storable::thaw $self->dbm->{$key}; | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 2 | ▶ | sub insert { | ||||||||||||||||||
|
Subroutine
insert: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 39 | 2 | my ( $self, $key, $value ) = @_; | |||||||||||||||||||
| 40 | 2 | $self->dbm->{$key} = Storable::freeze $value; | |||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | 0 | ▶ | sub update { shift->insert(@_) } | ||||||||||||||||||
|
Subroutine
update: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 0 | ▶ | sub delete { | ||||||||||||||||||
|
Subroutine
delete: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 45 | 0 | my ( $self, $key ) = @_; | |||||||||||||||||||
| 46 | 0 | delete $self->dbm->{$key}; | |||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 0 | ▶ | sub cleanup { Carp::croak "This storage doesn't support cleanup" } | ||||||||||||||||||
|
Subroutine
cleanup: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 2 | 1; | |||||||||||||||||||
| 52 | __END__ | ||||||||||||||||||||