line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of MooseX-Meta-TypeConstraint-Mooish |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2015 by Chris Weyl. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The GNU Lesser General Public License, Version 2.1, February 1999 |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
package MooseX::Meta::TypeConstraint::Mooish; |
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:RSRCHBOY'; |
12
|
|
|
|
|
|
|
# git description: e3cfe12 |
13
|
|
|
|
|
|
|
$MooseX::Meta::TypeConstraint::Mooish::VERSION = '0.001'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# ABSTRACT: Translate Moo-style constraints to Moose-style |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
520080
|
use Moose; |
|
2
|
|
|
|
|
237071
|
|
|
2
|
|
|
|
|
15
|
|
18
|
2
|
|
|
2
|
|
11995
|
use namespace::autoclean 0.24; |
|
2
|
|
|
|
|
2145
|
|
|
2
|
|
|
|
|
8
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
extends 'Moose::Meta::TypeConstraint'; |
21
|
|
|
|
|
|
|
with 'MooseX::TraitFor::Meta::TypeConstraint::Mooish'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(inline_constructor => 0); |
24
|
|
|
|
|
|
|
!!42; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
__END__ |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=pod |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=encoding UTF-8 |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=for :stopwords Chris Weyl |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=for :stopwords Wishlist flattr flattr'ed gittip gittip'ed |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 NAME |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
MooseX::Meta::TypeConstraint::Mooish - Translate Moo-style constraints to Moose-style |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 VERSION |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
This document describes version 0.001 of MooseX::Meta::TypeConstraint::Mooish - released March 12, 2015 as part of MooseX-Meta-TypeConstraint-Mooish. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# easiest is via AttributeShortcuts |
47
|
|
|
|
|
|
|
use MooseX::AttributeShortcuts 0.028; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has foo => ( |
50
|
|
|
|
|
|
|
is => 'rw', |
51
|
|
|
|
|
|
|
isa => sub { die unless $_[0] == 5 }, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# or, the hard way |
55
|
|
|
|
|
|
|
use MooseX::Meta::TypeConstraint::Mooish; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
has foo => ( |
58
|
|
|
|
|
|
|
is => 'rw', |
59
|
|
|
|
|
|
|
isa => MooseX::Meta::TypeConstraint::Mooish->new( |
60
|
|
|
|
|
|
|
constraint => sub { die unless $_[0] == 5 }, |
61
|
|
|
|
|
|
|
), |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 DESCRIPTION |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
L<Moose type constraints|Moose::Meta::TypeConstraint> are expected to return |
67
|
|
|
|
|
|
|
true if the value passes the constraint, and false otherwise; L<Moo> |
68
|
|
|
|
|
|
|
"constraints", on the other hand, die if validation fails. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This metaclass allows for Moo-style constraints; it will wrap them and |
71
|
|
|
|
|
|
|
translate their Moo into a dialect Moose understands. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Note that this is largely to enable functionality in |
74
|
|
|
|
|
|
|
L<MooseX::AttributeShortcuts>; the easiest way use this metaclass is by using |
75
|
|
|
|
|
|
|
that package. Also, as it's not inconceivable that this functionality may be |
76
|
|
|
|
|
|
|
desired in other constraint metaclasses, the bulk of this metaclass' |
77
|
|
|
|
|
|
|
functionality is implemented as |
78
|
|
|
|
|
|
|
L<a trait|MooseX::TraitFor::Meta::TypeConstraint::Mooish>. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 SEE ALSO |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Please see those modules/websites for more information related to this module. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=over 4 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item * |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
L<MooseX::AttributeShortcuts|MooseX::AttributeShortcuts> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item * |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
L<MooseX::TraitFor::Meta::TypeConstraint::Mooish|MooseX::TraitFor::Meta::TypeConstraint::Mooish> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=back |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 SOURCE |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
The development version is on github at L<http://https://github.com/RsrchBoy/moosex-meta-typeconstraint-mooish> |
99
|
|
|
|
|
|
|
and may be cloned from L<git://https://github.com/RsrchBoy/moosex-meta-typeconstraint-mooish.git> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 BUGS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website |
104
|
|
|
|
|
|
|
https://github.com/RsrchBoy/moosex-meta-typeconstraint-mooish/issues |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
107
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
108
|
|
|
|
|
|
|
feature. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 AUTHOR |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Chris Weyl <cweyl@alumni.drew.edu> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 I'm a material boy in a material world |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=begin html |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
<a href="https://www.gittip.com/RsrchBoy/"><img src="https://raw.githubusercontent.com/gittip/www.gittip.com/master/www/assets/%25version/logo.png" /></a> |
119
|
|
|
|
|
|
|
<a href="http://bit.ly/rsrchboys-wishlist"><img src="http://wps.io/wp-content/uploads/2014/05/amazon_wishlist.resized.png" /></a> |
120
|
|
|
|
|
|
|
<a href="https://flattr.com/submit/auto?user_id=RsrchBoy&url=https%3A%2F%2Fgithub.com%2FRsrchBoy%2Fmoosex-meta-typeconstraint-mooish&title=RsrchBoy's%20CPAN%20MooseX-Meta-TypeConstraint-Mooish&tags=%22RsrchBoy's%20MooseX-Meta-TypeConstraint-Mooish%20in%20the%20CPAN%22"><img src="http://api.flattr.com/button/flattr-badge-large.png" /></a> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=end html |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Please note B<I do not expect to be gittip'ed or flattr'ed for this work>, |
125
|
|
|
|
|
|
|
rather B<it is simply a very pleasant surprise>. I largely create and release |
126
|
|
|
|
|
|
|
works like this because I need them or I find it enjoyable; however, don't let |
127
|
|
|
|
|
|
|
that stop you if you feel like it ;) |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
L<Flattr this|https://flattr.com/submit/auto?user_id=RsrchBoy&url=https%3A%2F%2Fgithub.com%2FRsrchBoy%2Fmoosex-meta-typeconstraint-mooish&title=RsrchBoy's%20CPAN%20MooseX-Meta-TypeConstraint-Mooish&tags=%22RsrchBoy's%20MooseX-Meta-TypeConstraint-Mooish%20in%20the%20CPAN%22>, |
130
|
|
|
|
|
|
|
L<gittip me|https://www.gittip.com/RsrchBoy/>, or indulge my |
131
|
|
|
|
|
|
|
L<Amazon Wishlist|http://bit.ly/rsrchboys-wishlist>... If you so desire. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
This software is Copyright (c) 2015 by Chris Weyl. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
This is free software, licensed under: |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
The GNU Lesser General Public License, Version 2.1, February 1999 |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |