line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Type::Coercion::FromMoose; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
122
|
use 5.008001; |
|
5
|
|
|
|
|
21
|
|
4
|
5
|
|
|
5
|
|
32
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
114
|
|
5
|
5
|
|
|
5
|
|
28
|
use warnings; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
239
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
5
|
|
|
5
|
|
14
|
$Type::Coercion::FromMoose::AUTHORITY = 'cpan:TOBYINK'; |
9
|
5
|
|
|
|
|
221
|
$Type::Coercion::FromMoose::VERSION = '2.003_000'; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$Type::Coercion::FromMoose::VERSION =~ tr/_//d; |
13
|
|
|
|
|
|
|
|
14
|
5
|
|
|
5
|
|
38
|
use Scalar::Util qw< blessed >; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
342
|
|
15
|
5
|
|
|
5
|
|
32
|
use Types::TypeTiny (); |
|
5
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
1882
|
|
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
12
|
sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak } |
|
2
|
|
|
|
|
9
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
require Type::Coercion; |
20
|
|
|
|
|
|
|
our @ISA = 'Type::Coercion'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub type_coercion_map { |
23
|
26
|
|
|
26
|
1
|
39
|
my $self = shift; |
24
|
|
|
|
|
|
|
|
25
|
26
|
|
|
|
|
35
|
my @from; |
26
|
26
|
100
|
|
|
|
81
|
if ( $self->type_constraint ) { |
27
|
25
|
|
|
|
|
47
|
my $moose = $self->type_constraint->{moose_type}; |
28
|
25
|
50
|
33
|
|
|
82
|
@from = @{ $moose->coercion->type_coercion_map } |
|
25
|
|
|
|
|
1844
|
|
29
|
|
|
|
|
|
|
if $moose && $moose->has_coercion; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else { |
32
|
1
|
|
|
|
|
4
|
_croak |
33
|
|
|
|
|
|
|
"The type constraint attached to this coercion has been garbage collected... PANIC"; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
25
|
|
|
|
|
983
|
my @return; |
37
|
25
|
|
|
|
|
65
|
while ( @from ) { |
38
|
29
|
|
|
|
|
110
|
my ( $type, $code ) = splice( @from, 0, 2 ); |
39
|
29
|
100
|
|
|
|
97
|
$type = Moose::Util::TypeConstraints::find_type_constraint( $type ) |
40
|
|
|
|
|
|
|
unless ref $type; |
41
|
29
|
|
|
|
|
2506
|
push @return, Types::TypeTiny::to_TypeTiny( $type ), $code; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
25
|
|
|
|
|
205
|
return \@return; |
45
|
|
|
|
|
|
|
} #/ sub type_coercion_map |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub add_type_coercions { |
48
|
1
|
|
|
1
|
1
|
7
|
my $self = shift; |
49
|
1
|
50
|
|
|
|
5
|
_croak "Adding coercions to Type::Coercion::FromMoose not currently supported" |
50
|
|
|
|
|
|
|
if @_; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _build_moose_coercion { |
54
|
2
|
|
|
2
|
|
7
|
my $self = shift; |
55
|
|
|
|
|
|
|
|
56
|
2
|
100
|
|
|
|
7
|
if ( $self->type_constraint ) { |
57
|
1
|
|
|
|
|
4
|
my $moose = $self->type_constraint->{moose_type}; |
58
|
1
|
50
|
33
|
|
|
4
|
return $moose->coercion if $moose && $moose->has_coercion; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
11
|
$self->SUPER::_build_moose_coercion( @_ ); |
62
|
|
|
|
|
|
|
} #/ sub _build_moose_coercion |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub can_be_inlined { |
65
|
4
|
|
|
4
|
1
|
16
|
0; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=pod |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=encoding utf-8 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 NAME |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Type::Coercion::FromMoose - a set of coercions borrowed from Moose |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 STATUS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This module is considered part of Type-Tiny's internals. It is not |
83
|
|
|
|
|
|
|
covered by the |
84
|
|
|
|
|
|
|
L<Type-Tiny stability policy|Type::Tiny::Manual::Policies/"STABILITY">. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 DESCRIPTION |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This package inherits from L<Type::Coercion>; see that for most documentation. |
89
|
|
|
|
|
|
|
The major differences are that C<add_type_coercions> always throws an |
90
|
|
|
|
|
|
|
exception, and the C<type_coercion_map> is automatically populated from |
91
|
|
|
|
|
|
|
Moose. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This is mostly for internal purposes. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 BUGS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Please report any bugs to |
98
|
|
|
|
|
|
|
L<https://github.com/tobyink/p5-type-tiny/issues>. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 SEE ALSO |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
L<Type::Coercion>. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
L<Moose::Meta::TypeCoercion>. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Toby Inkster E<lt>tobyink@cpan.orgE<gt>. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This software is copyright (c) 2013-2014, 2017-2023 by Toby Inkster. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
115
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
120
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
121
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |