File Coverage

blib/lib/Bubblegum/Object/Role/Item.pm
Criterion Covered Total %
statement 23 26 88.4
branch 2 4 50.0
condition 1 3 33.3
subroutine 7 8 87.5
pod 0 4 0.0
total 33 45 73.3


line stmt bran cond sub pod time code
1             package Bubblegum::Object::Role::Item;
2              
3 37     37   16988 use 5.10.0;
  37         191  
  37         1750  
4 37     37   157 use namespace::autoclean;
  37         111  
  37         234  
5              
6 37     37   11933 use Bubblegum::Role 'requires';
  37         63  
  37         114  
7 37     37   26380 use Bubblegum::Namespace;
  37         53  
  37         247  
8              
9             our $VERSION = '0.45'; # VERSION
10              
11             requires 'defined';
12              
13             sub class {
14 0     0 0 0 my $self = CORE::shift;
15 0         0 my $types = $Bubblegum::Namespace::DefaultTypes;
16 0         0 return $types->{type($self)};
17             }
18              
19             sub of {
20 8     8 0 16 my $self = CORE::shift;
21 8         47 my $type = CORE::shift;
22 8         19 my $types = $Bubblegum::Namespace::DefaultTypes;
23              
24 8         85 my $alias = {
25             aref => 'array',
26             cref => 'code',
27             href => 'hash',
28             int => 'integer',
29             nil => 'undef',
30             null => 'undef',
31             num => 'number',
32             str => 'string',
33             undef => 'undef',
34             };
35              
36 8 50       47 $type = $alias->{lc $type} if $alias->{lc $type};
37              
38 8         32 my $kind = $types->{uc $type};
39 8         54 my $class = $self->autobox_class;
40              
41 8 50 33     350 return $kind && $class->isa($kind) ? 1 : 0;
42             }
43              
44             sub type {
45 93     93 0 129 my $self = CORE::shift;
46 93         463 return autobox::universal::type $self;
47             }
48              
49             sub typeof {
50 8     8 0 34 goto &of;
51             }
52              
53             1;