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.46'; |
5
|
|
|
|
|
|
|
|
6
|
17
|
|
|
17
|
|
75
|
use strict; |
|
17
|
|
|
|
|
29
|
|
|
17
|
|
|
|
|
381
|
|
7
|
17
|
|
|
17
|
|
76
|
use warnings; |
|
17
|
|
|
|
|
26
|
|
|
17
|
|
|
|
|
353
|
|
8
|
17
|
|
|
17
|
|
77
|
use Moose::Util::TypeConstraints (); |
|
17
|
|
|
|
|
27
|
|
|
17
|
|
|
|
|
237
|
|
9
|
17
|
|
|
17
|
|
75
|
use Moose::Exporter; |
|
17
|
|
|
|
|
33
|
|
|
17
|
|
|
|
|
133
|
|
10
|
17
|
|
|
17
|
|
466
|
use Carp; |
|
17
|
|
|
|
|
33
|
|
|
17
|
|
|
|
|
979
|
|
11
|
17
|
|
|
17
|
|
80
|
use namespace::autoclean; |
|
17
|
|
|
|
|
43
|
|
|
17
|
|
|
|
|
103
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $StringFoundMsg = |
14
|
|
|
|
|
|
|
q{WARNING: String found where Type expected (did you use a => instead of a , ?)}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my @exports = qw/type subtype maybe_type duck_type enum coerce from as/; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
19
|
|
|
|
|
|
|
#pod |
20
|
|
|
|
|
|
|
#pod Prevents errors like: |
21
|
|
|
|
|
|
|
#pod |
22
|
|
|
|
|
|
|
#pod subtype Foo => |
23
|
|
|
|
|
|
|
#pod ... |
24
|
|
|
|
|
|
|
#pod |
25
|
|
|
|
|
|
|
#pod Which should be written as: |
26
|
|
|
|
|
|
|
#pod |
27
|
|
|
|
|
|
|
#pod subtype Foo, |
28
|
|
|
|
|
|
|
#pod ... |
29
|
|
|
|
|
|
|
#pod |
30
|
|
|
|
|
|
|
#pod When using L<MooseX::Types>. Exported by that module. |
31
|
|
|
|
|
|
|
#pod |
32
|
|
|
|
|
|
|
#pod Exports checked versions of the following subs: |
33
|
|
|
|
|
|
|
#pod |
34
|
|
|
|
|
|
|
#pod C<type> C<subtype> C<maybe_type> C<duck_type> C<enum> C<coerce> C<from> C<as> |
35
|
|
|
|
|
|
|
#pod |
36
|
|
|
|
|
|
|
#pod While C<class_type> and C<role_type> will also register the type in the library. |
37
|
|
|
|
|
|
|
#pod |
38
|
|
|
|
|
|
|
#pod From L<Moose::Util::TypeConstraints>. See that module for syntax. |
39
|
|
|
|
|
|
|
#pod |
40
|
|
|
|
|
|
|
#pod =cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
for my $export (@exports) { |
43
|
17
|
|
|
17
|
|
1497
|
no strict 'refs'; |
|
17
|
|
|
|
|
26
|
|
|
17
|
|
|
|
|
4564
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Sub::Install::install_sub({ |
46
|
|
|
|
|
|
|
into => __PACKAGE__, |
47
|
|
|
|
|
|
|
as => $export, |
48
|
|
|
|
|
|
|
code => sub { |
49
|
140
|
|
|
140
|
|
1648
|
my $caller = shift; |
50
|
|
|
|
|
|
|
|
51
|
140
|
|
|
|
|
235
|
local $Carp::CarpLevel = $Carp::CarpLevel + 1; |
52
|
|
|
|
|
|
|
|
53
|
140
|
100
|
66
|
|
|
494
|
carp $StringFoundMsg |
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
54
|
|
|
|
|
|
|
unless ref($_[0]) || |
55
|
|
|
|
|
|
|
$_[0] =~ /\b::\b/ || # qualified type |
56
|
|
|
|
|
|
|
$caller->get_registered_class_type($_[0]) || |
57
|
|
|
|
|
|
|
$caller->get_registered_role_type($_[0]); |
58
|
|
|
|
|
|
|
|
59
|
139
|
|
|
|
|
181
|
goto &{"Moose::Util::TypeConstraints::$export"}; |
|
139
|
|
|
|
|
906
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
}); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Moose::Exporter->setup_import_methods( |
65
|
|
|
|
|
|
|
with_caller => [ @exports, 'class_type', 'role_type' ] |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub class_type { |
69
|
2
|
|
|
2
|
0
|
232
|
my $caller = shift; |
70
|
|
|
|
|
|
|
|
71
|
2
|
|
|
|
|
10
|
$caller->register_class_type( |
72
|
|
|
|
|
|
|
Moose::Util::TypeConstraints::class_type(@_) |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub role_type ($;$) { |
77
|
1
|
|
|
1
|
0
|
251
|
my ($caller, $name, $opts) = @_; |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
11
|
$caller->register_role_type( |
80
|
|
|
|
|
|
|
Moose::Util::TypeConstraints::role_type($name, $opts) |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
85
|
|
|
|
|
|
|
#pod |
86
|
|
|
|
|
|
|
#pod L<MooseX::Types> |
87
|
|
|
|
|
|
|
#pod |
88
|
|
|
|
|
|
|
#pod =cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=pod |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=encoding UTF-8 |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 NAME |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
MooseX::Types::CheckedUtilExports - Wrap L<Moose::Util::TypeConstraints> to be safer for L<MooseX::Types> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 VERSION |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
version 0.46 |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 DESCRIPTION |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Prevents errors like: |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
subtype Foo => |
111
|
|
|
|
|
|
|
... |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Which should be written as: |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
subtype Foo, |
116
|
|
|
|
|
|
|
... |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
When using L<MooseX::Types>. Exported by that module. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Exports checked versions of the following subs: |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
C<type> C<subtype> C<maybe_type> C<duck_type> C<enum> C<coerce> C<from> C<as> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
While C<class_type> and C<role_type> will also register the type in the library. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
From L<Moose::Util::TypeConstraints>. See that module for syntax. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 SEE ALSO |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
L<MooseX::Types> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 AUTHOR |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Robert "phaylon" Sedlacek <rs@474.at> |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This software is copyright (c) 2007 by Robert "phaylon" Sedlacek. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
141
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |