File Coverage

blib/lib/Bubblegum/Namespace.pm
Criterion Covered Total %
statement 12 22 54.5
branch 0 6 0.0
condition 0 6 0.0
subroutine 4 5 80.0
pod n/a
total 16 39 41.0


line stmt bran cond sub pod time code
1             package Bubblegum::Namespace;
2              
3 38     38   382 use 5.10.0;
  38         96  
  38         1586  
4              
5 38     38   196 use strict;
  38         61  
  38         1013  
6 38     38   164 use utf8::all;
  38         56  
  38         233  
7 38     38   50372 use warnings;
  38         61  
  38         14697  
8              
9             our $VERSION = '0.40'; # VERSION
10              
11             our $DefaultTypes = {
12             ARRAY => 'Bubblegum::Object::Array',
13             CODE => 'Bubblegum::Object::Code',
14             FLOAT => 'Bubblegum::Object::Float',
15             HASH => 'Bubblegum::Object::Hash',
16             INTEGER => 'Bubblegum::Object::Integer',
17             NUMBER => 'Bubblegum::Object::Number',
18             SCALAR => 'Bubblegum::Object::Scalar',
19             STRING => 'Bubblegum::Object::String',
20             UNDEF => 'Bubblegum::Object::Undef',
21             UNIVERSAL => 'Bubblegum::Object::Universal',
22             };
23              
24             our $ExtendedTypes = {
25             %$DefaultTypes => (
26             INSTANCE => 'Bubblegum::Object::Instance',
27             WRAPPER => 'Bubblegum::Wrapper'
28             ),
29             };
30              
31             sub import {
32 0     0     my $class = shift;
33 0 0 0       my %args = ((@_ == 1) && 'HASH' eq ref $_[0]) ? %{shift()} : @_;
  0            
34              
35 0           for my $type (keys %args) {
36 0           my $class = $args{$type};
37 0           $type = uc $type;
38 0 0         if (exists $$ExtendedTypes{$type}) {
39 0   0       $$ExtendedTypes{$type} = $class // $$DefaultTypes{$type};
40 0 0         eval "use $class" if $class;
41             }
42             }
43              
44 0           return $class;
45             }
46              
47             1;