File Coverage

blib/lib/Bubblegum/Namespace.pm
Criterion Covered Total %
statement 51 52 98.0
branch 3 6 50.0
condition 2 6 33.3
subroutine 15 15 100.0
pod n/a
total 71 79 89.8


line stmt bran cond sub pod time code
1             package Bubblegum::Namespace;
2              
3 39     39   312 use 5.10.0;
  39         84  
  39         1404  
4              
5 39     39   161 use strict;
  39         49  
  39         976  
6 39     39   130 use utf8::all;
  39         50  
  39         189  
7 39     39   44927 use warnings;
  39         55  
  39         12616  
8              
9             our $VERSION = '0.45'; # 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 86     86   268 my $class = shift;
33 0         0 my %args = ((@_ == 1) &&
34 86 50 33     3045 'HASH' eq ref $_[0]) ? %{shift()} : @_;
35              
36 86         306 for my $type (keys %args) {
37 10         16 my $class = $args{$type};
38 10         19 $type = uc $type;
39 10 50       34 if (exists $$ExtendedTypes{$type}) {
40 10   33     30 $$ExtendedTypes{$type} = $class // $$DefaultTypes{$type};
41 10 50   1   737 eval "use $class" if $class;
  1     1   330  
  1     1   95  
  1     1   40  
  1     1   317  
  1     1   83  
  1     1   32  
  1     1   366  
  1     1   82  
  1     1   64  
  1         311  
  1         87  
  1         41  
  1         313  
  1         93  
  1         43  
  1         336  
  1         97  
  1         34  
  1         333  
  1         102  
  1         37  
  1         331  
  1         98  
  1         55  
  1         392  
  1         76  
  1         37  
  1         320  
  1         89  
  1         31  
42             }
43             }
44              
45 86         10782 return $class;
46             }
47              
48             1;