DB/Factory.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 28 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Audio::DB::Factory;
2  
3 use strict 'vars';
4 use Carp 'croak';
5 use vars '@ISA';
6  
7 use Audio::DB::Util::Rearrange;
8  
9 # Objects can either be created with a pre-fetched jasj reference
10 # or with an object id (like an album id).
11  
12 sub new {
13 my ($self,@p) = @_;
14 my ($class,$data) = rearrange([qw/CLASS DATA/],@p);
15
16 # Yuck - I need to transform the class (which is really a table name) into
17 # a package name. Stupidity reins supreme
18 # THIS MIGHT BE DEPRECATED NOW BUT LEAVE IN PLACE SO THAT PEOPLE
19 # can call the Factory with artist or artists.
20  
21 $class =~ s/s$//;
22 my $package = "Audio::DB::DataTypes::" . ucfirst $class;
23  
24 my $this = bless {},$package;
25 foreach (keys %$data) {
26 $this->{$_} = $data->{$_}
27 }
28 return $this;
29 }
30  
31  
32 1;
33