line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Moose::Meta::TypeCoercion::Union; |
2
|
|
|
|
|
|
|
our $VERSION = '2.2205'; |
3
|
|
|
|
|
|
|
|
4
|
390
|
|
|
390
|
|
2963
|
use strict; |
|
390
|
|
|
|
|
914
|
|
|
390
|
|
|
|
|
12134
|
|
5
|
390
|
|
|
390
|
|
2138
|
use warnings; |
|
390
|
|
|
|
|
944
|
|
|
390
|
|
|
|
|
9736
|
|
6
|
390
|
|
|
390
|
|
2026
|
use metaclass; |
|
390
|
|
|
|
|
945
|
|
|
390
|
|
|
|
|
2145
|
|
7
|
|
|
|
|
|
|
|
8
|
390
|
|
|
390
|
|
3097
|
use Scalar::Util 'blessed'; |
|
390
|
|
|
|
|
1100
|
|
|
390
|
|
|
|
|
21834
|
|
9
|
|
|
|
|
|
|
|
10
|
390
|
|
|
390
|
|
2835
|
use parent 'Moose::Meta::TypeCoercion'; |
|
390
|
|
|
|
|
1259
|
|
|
390
|
|
|
|
|
2975
|
|
11
|
|
|
|
|
|
|
|
12
|
390
|
|
|
390
|
|
28181
|
use Moose::Util 'throw_exception'; |
|
390
|
|
|
|
|
1221
|
|
|
390
|
|
|
|
|
2741
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub compile_type_coercion { |
15
|
5
|
|
|
5
|
0
|
12
|
my $self = shift; |
16
|
5
|
|
|
|
|
178
|
my $type_constraint = $self->type_constraint; |
17
|
|
|
|
|
|
|
|
18
|
5
|
100
|
66
|
|
|
89
|
(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
|
|
24
|
my $value = shift; |
26
|
|
|
|
|
|
|
|
27
|
7
|
|
|
|
|
15
|
foreach my $type ( grep { $_->has_coercion } |
|
14
|
|
|
|
|
426
|
|
28
|
7
|
|
|
|
|
248
|
@{ $type_constraint->type_constraints } ) { |
29
|
11
|
|
|
|
|
42
|
my $temp = $type->coerce($value); |
30
|
11
|
100
|
|
|
|
96
|
return $temp if $type_constraint->check($temp); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
5
|
return $value; |
34
|
|
|
|
|
|
|
} |
35
|
4
|
|
|
|
|
171
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
1
|
0
|
sub has_coercion_for_type { 0 } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub add_type_coercions { |
41
|
1
|
|
|
1
|
1
|
90
|
my $self = shift; |
42
|
1
|
|
|
|
|
4
|
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.2205 |
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 |