line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Moose::Meta::TypeCoercion::Union; |
2
|
|
|
|
|
|
|
our $VERSION = '2.2206'; |
3
|
|
|
|
|
|
|
|
4
|
390
|
|
|
390
|
|
2788
|
use strict; |
|
390
|
|
|
|
|
881
|
|
|
390
|
|
|
|
|
11850
|
|
5
|
390
|
|
|
390
|
|
2162
|
use warnings; |
|
390
|
|
|
|
|
898
|
|
|
390
|
|
|
|
|
9312
|
|
6
|
390
|
|
|
390
|
|
2019
|
use metaclass; |
|
390
|
|
|
|
|
908
|
|
|
390
|
|
|
|
|
2198
|
|
7
|
|
|
|
|
|
|
|
8
|
390
|
|
|
390
|
|
3043
|
use Scalar::Util 'blessed'; |
|
390
|
|
|
|
|
1049
|
|
|
390
|
|
|
|
|
21569
|
|
9
|
|
|
|
|
|
|
|
10
|
390
|
|
|
390
|
|
3073
|
use parent 'Moose::Meta::TypeCoercion'; |
|
390
|
|
|
|
|
1249
|
|
|
390
|
|
|
|
|
2725
|
|
11
|
|
|
|
|
|
|
|
12
|
390
|
|
|
390
|
|
27618
|
use Moose::Util 'throw_exception'; |
|
390
|
|
|
|
|
1263
|
|
|
390
|
|
|
|
|
2776
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub compile_type_coercion { |
15
|
5
|
|
|
5
|
0
|
11
|
my $self = shift; |
16
|
5
|
|
|
|
|
163
|
my $type_constraint = $self->type_constraint; |
17
|
|
|
|
|
|
|
|
18
|
5
|
100
|
66
|
|
|
115
|
(blessed $type_constraint && $type_constraint->isa('Moose::Meta::TypeConstraint::Union')) |
19
|
|
|
|
|
|
|
|| throw_exception( NeedsTypeConstraintUnionForTypeCoercionUnion => type_coercion_union_object => $self, |
20
|
|
|
|
|
|
|
type_name => $type_constraint->name |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$self->_compiled_type_coercion( |
24
|
|
|
|
|
|
|
sub { |
25
|
7
|
|
|
7
|
|
14
|
my $value = shift; |
26
|
|
|
|
|
|
|
|
27
|
7
|
|
|
|
|
11
|
foreach my $type ( grep { $_->has_coercion } |
|
14
|
|
|
|
|
329
|
|
28
|
7
|
|
|
|
|
167
|
@{ $type_constraint->type_constraints } ) { |
29
|
11
|
|
|
|
|
26
|
my $temp = $type->coerce($value); |
30
|
11
|
100
|
|
|
|
75
|
return $temp if $type_constraint->check($temp); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
3
|
return $value; |
34
|
|
|
|
|
|
|
} |
35
|
4
|
|
|
|
|
159
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
1
|
0
|
sub has_coercion_for_type { 0 } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub add_type_coercions { |
41
|
1
|
|
|
1
|
1
|
105
|
my $self = shift; |
42
|
1
|
|
|
|
|
5
|
throw_exception( CannotAddAdditionalTypeCoercionsToUnion => type_coercion_union_object => $self ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# ABSTRACT: The Moose Type Coercion metaclass for Unions |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=pod |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=encoding UTF-8 |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Moose::Meta::TypeCoercion::Union - The Moose Type Coercion metaclass for Unions |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 VERSION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
version 2.2206 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 DESCRIPTION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This is a subclass of L<Moose::Meta::TypeCoercion> that is used for |
66
|
|
|
|
|
|
|
L<Moose::Meta::TypeConstraint::Union> objects. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 METHODS |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 $coercion->has_coercion_for_type |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This method always returns false. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 $coercion->add_type_coercions |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This method always throws an error. You cannot add coercions to a |
77
|
|
|
|
|
|
|
union type coercion. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 $coercion->coerce($value) |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This method will coerce by trying the coercions for each type in the |
82
|
|
|
|
|
|
|
union. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 BUGS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
See L<Moose/BUGS> for details on reporting bugs. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 AUTHORS |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=over 4 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item * |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Stevan Little <stevan@cpan.org> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item * |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item * |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Jesse Luehrs <doy@cpan.org> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Shawn M Moore <sartak@cpan.org> |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item * |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item * |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Hans Dieter Pearcey <hdp@cpan.org> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item * |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Chris Prather <chris@prather.org> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item * |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Matt S Trout <mstrout@cpan.org> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=back |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This software is copyright (c) 2006 by Infinity Interactive, Inc. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
139
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |