File Coverage

blib/lib/Text/Xslate/Bridge/TypeDeclaration/Registry.pm
Criterion Covered Total %
statement 25 25 100.0
branch 6 6 100.0
condition 3 3 100.0
subroutine 7 7 100.0
pod 3 3 100.0
total 44 44 100.0


line stmt bran cond sub pod time code
1             package Text::Xslate::Bridge::TypeDeclaration::Registry;
2 11     11   107222 use strict;
  11         33  
  11         695  
3 11     11   96 use warnings;
  11         35  
  11         659  
4 11     11   74 use parent qw(Type::Registry);
  11         29  
  11         99  
5              
6             # override
7             sub new {
8 54     54 1 275236 my ($class) = @_;
9 54         454 my $self = $class->SUPER::new;
10 54         814 $self->add_types('Types::Standard');
11 54         326415 return $self;
12             }
13              
14             # override
15             sub simple_lookup {
16 196     196 1 107745 my ($self, $name, $flag) = @_;
17 196         1798 my $type = $self->SUPER::simple_lookup($name, $flag);
18              
19             # Given 1 to $flag when parsing a name (undocumented)
20 196 100 100     3881 return (!defined $type && $flag)
21             ? $self->_class_type($name) : $type;
22             }
23              
24             # override
25             sub foreign_lookup {
26 26     26 1 10581 my ($self, $name, $flag) = @_;
27 26         163 my $type = $self->SUPER::foreign_lookup($name, $flag);
28 26 100       7952 return $type ? $type : $self->_class_type($name);
29             }
30              
31             sub _class_type {
32 27     27   163 my ($self, $name) = @_;
33              
34 27         218 my $type = $self->SUPER::simple_lookup($name);
35 27 100       424 unless ($type) {
36 26         219 $type = $self->make_class_type($name);
37 26         16493 $self->add_type($type, $name);
38             }
39              
40 27         847 return $type;
41             }
42              
43             1;
44              
45             __END__