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