File Coverage

blib/lib/Text/Xslate/Bridge/TypeDeclaration/Registry.pm
Criterion Covered Total %
statement 28 28 100.0
branch 6 6 100.0
condition 3 3 100.0
subroutine 8 8 100.0
pod 3 3 100.0
total 48 48 100.0


line stmt bran cond sub pod time code
1             package Text::Xslate::Bridge::TypeDeclaration::Registry;
2 11     11   94196 use strict;
  11         27  
  11         425  
3 11     11   68 use warnings;
  11         29  
  11         379  
4 11     11   67 use parent qw(Type::Registry);
  11         26  
  11         87  
5              
6 11     11   104761 use Type::Tiny::Class;
  11         146217  
  11         2332  
7              
8             # override
9             sub new {
10 54     54 1 208518 my ($class) = @_;
11 54         406 my $self = $class->SUPER::new;
12 54         753 $self->add_types('Types::Standard');
13 54         262886 return $self;
14             }
15              
16             # override
17             sub simple_lookup {
18 204     204 1 82778 my ($self, $name, $flag) = @_;
19 204         738 my $type = $self->SUPER::simple_lookup($name, $flag);
20              
21             # Given 1 to $flag when parsing a name (undocumented)
22 204 100 100     3305 return (!defined $type && $flag)
23             ? $self->_class_type($name) : $type;
24             }
25              
26             # override
27             sub foreign_lookup {
28 28     28 1 7489 my ($self, $name, $flag) = @_;
29 28         151 my $type = $self->SUPER::foreign_lookup($name, $flag);
30 28 100       6887 return $type ? $type : $self->_class_type($name);
31             }
32              
33             sub _class_type {
34 30     30   123 my ($self, $name) = @_;
35              
36 30         123 my $type = $self->SUPER::simple_lookup($name);
37 30 100       447 unless ($type) {
38 29         261 $type = Type::Tiny::Class->new(class => $name, display_name => $name);
39 29         4776 $self->add_type($type, $name);
40             }
41              
42 30         809 return $type;
43             }
44              
45             1;
46              
47             __END__