File Coverage

blib/lib/ObjectDB/Factory.pm
Criterion Covered Total %
statement 22 23 95.6
branch 1 2 50.0
condition n/a
subroutine 5 6 83.3
pod 0 3 0.0
total 28 34 82.3


line stmt bran cond sub pod time code
1             package ObjectDB::Factory;
2              
3 5     5   64 use strict;
  5         8  
  5         112  
4 5     5   22 use warnings;
  5         6  
  5         177  
5              
6             our $VERSION = '3.26';
7              
8             require Carp;
9 5     5   1734 use ObjectDB::Util qw(load_class);
  5         11  
  5         838  
10              
11             sub new {
12 5     5 0 8 my $class = shift;
13              
14 5         7 my $self = {};
15 5         9 bless $self, $class;
16              
17 5         11 return $self;
18             }
19              
20 0     0 0 0 sub namespace { Carp::croak('implement') }
21              
22             sub build {
23 5     5 0 17 my $self = shift;
24 5         7 my $type = shift;
25 5         14 my %params = @_;
26              
27 5 50       9 Carp::croak('type is required') unless $type;
28              
29 5         13 my @parts = map { ucfirst } split q{ }, $type;
  15         29  
30 5         14 my $rel_class = $self->namespace . join q{}, @parts;
31              
32 5         14 load_class $rel_class;
33              
34 5         31 return $rel_class->new(%params);
35             }
36              
37             1;