| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MooseX::Types::CheckedUtilExports; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: Wrap L<Moose::Util::TypeConstraints> to be safer for L<MooseX::Types> |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.50'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
18
|
|
|
18
|
|
80
|
use strict; |
|
|
18
|
|
|
|
|
26
|
|
|
|
18
|
|
|
|
|
536
|
|
|
7
|
18
|
|
|
18
|
|
80
|
use warnings; |
|
|
18
|
|
|
|
|
26
|
|
|
|
18
|
|
|
|
|
483
|
|
|
8
|
18
|
|
|
18
|
|
81
|
use Moose::Util::TypeConstraints (); |
|
|
18
|
|
|
|
|
26
|
|
|
|
18
|
|
|
|
|
328
|
|
|
9
|
18
|
|
|
18
|
|
76
|
use Moose::Exporter; |
|
|
18
|
|
|
|
|
20
|
|
|
|
18
|
|
|
|
|
157
|
|
|
10
|
18
|
|
|
18
|
|
733
|
use Carp 'carp'; |
|
|
18
|
|
|
|
|
31
|
|
|
|
18
|
|
|
|
|
1102
|
|
|
11
|
18
|
|
|
18
|
|
94
|
use Sub::Install; |
|
|
18
|
|
|
|
|
23
|
|
|
|
18
|
|
|
|
|
174
|
|
|
12
|
18
|
|
|
18
|
|
586
|
use namespace::autoclean; |
|
|
18
|
|
|
|
|
31
|
|
|
|
18
|
|
|
|
|
120
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $StringFoundMsg = |
|
15
|
|
|
|
|
|
|
q{WARNING: String found where Type expected (did you use a => instead of a , ?)}; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my @exports = qw/type subtype maybe_type duck_type enum coerce from as/; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
|
20
|
|
|
|
|
|
|
#pod |
|
21
|
|
|
|
|
|
|
#pod Prevents errors like: |
|
22
|
|
|
|
|
|
|
#pod |
|
23
|
|
|
|
|
|
|
#pod subtype Foo => |
|
24
|
|
|
|
|
|
|
#pod ... |
|
25
|
|
|
|
|
|
|
#pod |
|
26
|
|
|
|
|
|
|
#pod Which should be written as: |
|
27
|
|
|
|
|
|
|
#pod |
|
28
|
|
|
|
|
|
|
#pod subtype Foo, |
|
29
|
|
|
|
|
|
|
#pod ... |
|
30
|
|
|
|
|
|
|
#pod |
|
31
|
|
|
|
|
|
|
#pod When using L<MooseX::Types>. Exported by that module. |
|
32
|
|
|
|
|
|
|
#pod |
|
33
|
|
|
|
|
|
|
#pod Exports checked versions of the following subs: |
|
34
|
|
|
|
|
|
|
#pod |
|
35
|
|
|
|
|
|
|
#pod C<type> C<subtype> C<maybe_type> C<duck_type> C<enum> C<coerce> C<from> C<as> |
|
36
|
|
|
|
|
|
|
#pod |
|
37
|
|
|
|
|
|
|
#pod While C<class_type> and C<role_type> will also register the type in the library. |
|
38
|
|
|
|
|
|
|
#pod |
|
39
|
|
|
|
|
|
|
#pod From L<Moose::Util::TypeConstraints>. See that module for syntax. |
|
40
|
|
|
|
|
|
|
#pod |
|
41
|
|
|
|
|
|
|
#pod =for Pod::Coverage class_type role_type |
|
42
|
|
|
|
|
|
|
#pod |
|
43
|
|
|
|
|
|
|
#pod =cut |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
for my $export (@exports) { |
|
46
|
18
|
|
|
18
|
|
2048
|
no strict 'refs'; |
|
|
18
|
|
|
|
|
36
|
|
|
|
18
|
|
|
|
|
5888
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Sub::Install::install_sub({ |
|
49
|
|
|
|
|
|
|
into => __PACKAGE__, |
|
50
|
|
|
|
|
|
|
as => $export, |
|
51
|
|
|
|
|
|
|
code => sub { |
|
52
|
156
|
|
|
156
|
|
1937
|
my $caller = shift; |
|
53
|
|
|
|
|
|
|
|
|
54
|
156
|
|
|
|
|
212
|
local $Carp::CarpLevel = $Carp::CarpLevel + 1; |
|
55
|
|
|
|
|
|
|
|
|
56
|
156
|
100
|
66
|
|
|
493
|
carp $StringFoundMsg |
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
57
|
|
|
|
|
|
|
unless ref($_[0]) || |
|
58
|
|
|
|
|
|
|
$_[0] =~ /\b::\b/ || # qualified type |
|
59
|
|
|
|
|
|
|
$caller->get_registered_class_type($_[0]) || |
|
60
|
|
|
|
|
|
|
$caller->get_registered_role_type($_[0]); |
|
61
|
|
|
|
|
|
|
|
|
62
|
155
|
|
|
|
|
173
|
goto &{"Moose::Util::TypeConstraints::$export"}; |
|
|
155
|
|
|
|
|
1116
|
|
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
}); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Moose::Exporter->setup_import_methods( |
|
68
|
|
|
|
|
|
|
with_caller => [ @exports, 'class_type', 'role_type' ] |
|
69
|
|
|
|
|
|
|
); |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub class_type { |
|
72
|
2
|
|
|
2
|
0
|
204
|
my $caller = shift; |
|
73
|
|
|
|
|
|
|
|
|
74
|
2
|
|
|
|
|
13
|
$caller->register_class_type( |
|
75
|
|
|
|
|
|
|
Moose::Util::TypeConstraints::class_type(@_) |
|
76
|
|
|
|
|
|
|
); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub role_type ($;$) { |
|
80
|
1
|
|
|
1
|
0
|
291
|
my ($caller, $name, $opts) = @_; |
|
81
|
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
17
|
$caller->register_role_type( |
|
83
|
|
|
|
|
|
|
Moose::Util::TypeConstraints::role_type($name, $opts) |
|
84
|
|
|
|
|
|
|
); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
|
88
|
|
|
|
|
|
|
#pod |
|
89
|
|
|
|
|
|
|
#pod L<MooseX::Types> |
|
90
|
|
|
|
|
|
|
#pod |
|
91
|
|
|
|
|
|
|
#pod =cut |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=pod |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=encoding UTF-8 |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 NAME |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
MooseX::Types::CheckedUtilExports - Wrap L<Moose::Util::TypeConstraints> to be safer for L<MooseX::Types> |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 VERSION |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
version 0.50 |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Prevents errors like: |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
subtype Foo => |
|
114
|
|
|
|
|
|
|
... |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Which should be written as: |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
subtype Foo, |
|
119
|
|
|
|
|
|
|
... |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
When using L<MooseX::Types>. Exported by that module. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Exports checked versions of the following subs: |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
C<type> C<subtype> C<maybe_type> C<duck_type> C<enum> C<coerce> C<from> C<as> |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
While C<class_type> and C<role_type> will also register the type in the library. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
From L<Moose::Util::TypeConstraints>. See that module for syntax. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=for Pod::Coverage class_type role_type |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
L<MooseX::Types> |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 SUPPORT |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Types> |
|
140
|
|
|
|
|
|
|
(or L<bug-MooseX-Types@rt.cpan.org|mailto:bug-MooseX-Types@rt.cpan.org>). |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
There is also a mailing list available for users of this distribution, at |
|
143
|
|
|
|
|
|
|
L<http://lists.perl.org/list/moose.html>. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
There is also an irc channel available for users of this distribution, at |
|
146
|
|
|
|
|
|
|
L<C<#moose> on C<irc.perl.org>|irc://irc.perl.org/#moose>. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 AUTHOR |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Robert "phaylon" Sedlacek <rs@474.at> |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This software is copyright (c) 2007 by Robert "phaylon" Sedlacek. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
157
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |