File Coverage

blib/lib/Class/Accessor/Typed/TypeTiny.pm
Criterion Covered Total %
statement 18 34 52.9
branch 0 8 0.0
condition n/a
subroutine 6 8 75.0
pod 0 2 0.0
total 24 52 46.1


line stmt bran cond sub pod time code
1             package Class::Accessor::Typed::TypeTiny;
2 1     1   12619 use strict;
  1         2  
  1         21  
3 1     1   5 use warnings;
  1         1  
  1         18  
4 1     1   4 use utf8;
  1         2  
  1         5  
5              
6 1     1   17 use Scalar::Util qw/blessed/;
  1         2  
  1         32  
7 1     1   334 use Type::Registry;
  1         7454  
  1         6  
8 1     1   430 use Type::Utils;
  1         6340  
  1         7  
9              
10             my $reg = Type::Registry->for_class(__PACKAGE__);
11              
12             sub type {
13 0     0 0   my ($class, $type_name) = @_;
14 0 0         return $type_name if blessed($type_name);
15              
16 0 0         if (my $type = $reg->simple_lookup($type_name)) {
17 0           return $type;
18             } else {
19 0           my $type = Type::Utils::dwim_type(
20             $type_name,
21             fallback => [ 'lookup_via_mouse', 'make_class_type' ],
22             );
23 0           $type->{display_name} = $type_name;
24 0           $reg->add_type($type, $type_name);
25 0           return $type;
26             }
27             }
28              
29             sub type_role {
30 0     0 0   my ($class, $type_name) = @_;
31 0 0         return $type_name if blessed($type_name);
32              
33 0 0         if (my $type = $reg->simple_lookup($type_name)) {
34 0           return $type;
35             } else {
36 0           my $type = Type::Utils::dwim_type(
37             $type_name,
38             fallback => ['make_role_type'],
39             );
40 0           $type->{display_name} = $type_name;
41 0           $reg->add_type($type, $type_name);
42 0           return $type;
43             }
44             }
45              
46             1;