Amethyst/Store.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 58 CC 3 SCAR 14.6
CC
3
Cov
0%
new
12.0
get
2.0
set
2.0
CRAP 4.3
1 package Amethyst::Store;
2  
3 use strict;
4 use vars qw(@ISA @EXPORT);
5 use Carp;
6 use Exporter;
7 use MLDBM qw(DB_File Storable);
8 use Fcntl;
9 # use POE;
10 # use Amethyst;
11  
12 @ISA = qw(Exporter);
13 @EXPORT = qw();
14  
15 sub new {
16 my $class = shift;
17 my $self = ($#_ == 0) ? { %{ (shift) } } : { @_ };
18 die "No source for store" unless $self->{Source};
19 my %data;
20 my $dbm = tie %data, 'MLDBM', $self->{Source}, O_CREAT|O_RDWR, 0640
21 or die "tie: $self->{Source}: $!";
22 $self->{Data} = \%data;
23 return bless $self, $class;
24 }
25  
26 sub get { return $_[0]->{Data}->{$_[1]}; }
27 sub set { $_[0]->{Data}->{$_[1]} = $_[2]; }
28 sub unset { delete $_[0]->{Data}->{$_[1]}; }
29 sub keys { return keys %{ $_[0]->{Data} }; }
30  
31 1;