line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Boundary::Types; |
2
|
2
|
|
|
2
|
|
72828
|
use strict; |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
61
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
78
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
|
|
20
|
use Type::Library -base, |
6
|
2
|
|
|
2
|
|
1064
|
-declare => qw( ImplOf ); |
|
2
|
|
|
|
|
50258
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
2159
|
use Boundary (); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
51
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
1222
|
use Types::Standard -types; |
|
2
|
|
|
|
|
104150
|
|
|
2
|
|
|
|
|
45
|
|
11
|
2
|
|
|
2
|
|
9774
|
use Class::Load qw(is_class_loaded); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
135
|
|
12
|
2
|
|
|
2
|
|
13
|
use Scalar::Util qw(blessed); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
536
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
__PACKAGE__->add_type({ |
15
|
|
|
|
|
|
|
name => 'ImplOf', |
16
|
|
|
|
|
|
|
parent => Object, |
17
|
|
|
|
|
|
|
constraint_generator => sub { |
18
|
|
|
|
|
|
|
my $self = $Type::Tiny::parameterize_type; |
19
|
|
|
|
|
|
|
my @interfaces = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $display_name = $self->name_generator->($self, @interfaces); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my %options = ( |
24
|
|
|
|
|
|
|
constraint => sub { |
25
|
|
|
|
|
|
|
my ($target) = @_; |
26
|
|
|
|
|
|
|
my $impl = blessed($target); |
27
|
|
|
|
|
|
|
return if !$impl; |
28
|
|
|
|
|
|
|
return Boundary->check_implementations($impl, @interfaces); |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
display_name => $display_name, |
31
|
|
|
|
|
|
|
parameters => [@interfaces], |
32
|
|
|
|
|
|
|
message => sub { |
33
|
|
|
|
|
|
|
my $impl = blessed($_); |
34
|
|
|
|
|
|
|
return "$_ is not blessed" if !$impl; |
35
|
|
|
|
|
|
|
return "$impl not loaded" if !is_class_loaded($impl); |
36
|
|
|
|
|
|
|
return sprintf '%s did not pass type constraint "%s"', Type::Tiny::_dd($_), $display_name; |
37
|
|
|
|
|
|
|
}, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
return $self->create_child_type(%options); |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
}); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |