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   84 use strict;
  5         11  
  5         140  
4 5     5   24 use warnings;
  5         18  
  5         243  
5              
6             our $VERSION = '3.27';
7              
8             require Carp;
9 5     5   2165 use ObjectDB::Util qw(load_class);
  5         13  
  5         1038  
10              
11             sub new {
12 5     5 0 9 my $class = shift;
13              
14 5         10 my $self = {};
15 5         9 bless $self, $class;
16              
17 5         12 return $self;
18             }
19              
20 0     0 0 0 sub namespace { Carp::croak('implement') }
21              
22             sub build {
23 5     5 0 7 my $self = shift;
24 5         10 my $type = shift;
25 5         16 my %params = @_;
26              
27 5 50       13 Carp::croak('type is required') unless $type;
28              
29 5         16 my @parts = map { ucfirst } split q{ }, $type;
  15         36  
30 5         18 my $rel_class = $self->namespace . join q{}, @parts;
31              
32 5         20 load_class $rel_class;
33              
34 5         37 return $rel_class->new(%params);
35             }
36              
37             1;