line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Moose::Meta::TypeCoercion::Union; |
2
|
|
|
|
|
|
|
our $VERSION = '2.2203'; |
3
|
|
|
|
|
|
|
|
4
|
401
|
|
|
401
|
|
2626
|
use strict; |
|
401
|
|
|
|
|
822
|
|
|
401
|
|
|
|
|
10904
|
|
5
|
401
|
|
|
401
|
|
1879
|
use warnings; |
|
401
|
|
|
|
|
815
|
|
|
401
|
|
|
|
|
8318
|
|
6
|
401
|
|
|
401
|
|
1879
|
use metaclass; |
|
401
|
|
|
|
|
797
|
|
|
401
|
|
|
|
|
2013
|
|
7
|
|
|
|
|
|
|
|
8
|
401
|
|
|
401
|
|
2784
|
use Scalar::Util 'blessed'; |
|
401
|
|
|
|
|
913
|
|
|
401
|
|
|
|
|
20229
|
|
9
|
|
|
|
|
|
|
|
10
|
401
|
|
|
401
|
|
2692
|
use parent 'Moose::Meta::TypeCoercion'; |
|
401
|
|
|
|
|
999
|
|
|
401
|
|
|
|
|
2468
|
|
11
|
|
|
|
|
|
|
|
12
|
401
|
|
|
401
|
|
25967
|
use Moose::Util 'throw_exception'; |
|
401
|
|
|
|
|
1009
|
|
|
401
|
|
|
|
|
2517
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub compile_type_coercion { |
15
|
5
|
|
|
5
|
0
|
12
|
my $self = shift; |
16
|
5
|
|
|
|
|
179
|
my $type_constraint = $self->type_constraint; |
17
|
|
|
|
|
|
|
|
18
|
5
|
100
|
66
|
|
|
78
|
(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
|
|
|
|
|
10
|
foreach my $type ( grep { $_->has_coercion } |
|
14
|
|
|
|
|
421
|
|
28
|
7
|
|
|
|
|
215
|
@{ $type_constraint->type_constraints } ) { |
29
|
11
|
|
|
|
|
36
|
my $temp = $type->coerce($value); |
30
|
11
|
100
|
|
|
|
90
|
return $temp if $type_constraint->check($temp); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
5
|
return $value; |
34
|
|
|
|
|
|
|
} |
35
|
4
|
|
|
|
|
164
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
1
|
0
|
sub has_coercion_for_type { 0 } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub add_type_coercions { |
41
|
1
|
|
|
1
|
1
|
64
|
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.2203 |
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 |