Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / Moose::Meta::TypeConstraint.3pm
1 .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.3
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sh \" Subsection heading
6 .br
7 .if t .Sp
8 .ne 5
9 .PP
10 \fB\\$1\fR
11 .PP
12 ..
13 .de Sp \" Vertical space (when we can't use .PP)
14 .if t .sp .5v
15 .if n .sp
16 ..
17 .de Vb \" Begin verbatim text
18 .ft CW
19 .nf
20 .ne \\$1
21 ..
22 .de Ve \" End verbatim text
23 .ft R
24 .fi
25 ..
26 .\" Set up some character translations and predefined strings.  \*(-- will
27 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28 .\" double quote, and \*(R" will give a right double quote.  | will give a
29 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
30 .\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
31 .\" expand to `' in nroff, nothing in troff, for use with C<>.
32 .tr \(*W-|\(bv\*(Tr
33 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34 .ie n \{\
35 .    ds -- \(*W-
36 .    ds PI pi
37 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
39 .    ds L" ""
40 .    ds R" ""
41 .    ds C` ""
42 .    ds C' ""
43 'br\}
44 .el\{\
45 .    ds -- \|\(em\|
46 .    ds PI \(*p
47 .    ds L" ``
48 .    ds R" ''
49 'br\}
50 .\"
51 .\" If the F register is turned on, we'll generate index entries on stderr for
52 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53 .\" entries marked with X<> in POD.  Of course, you'll have to process the
54 .\" output yourself in some meaningful fashion.
55 .if \nF \{\
56 .    de IX
57 .    tm Index:\\$1\t\\n%\t"\\$2"
58 ..
59 .    nr % 0
60 .    rr F
61 .\}
62 .\"
63 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
64 .\" way too many mistakes in technical documents.
65 .hy 0
66 .if n .na
67 .\"
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70 .    \" fudge factors for nroff and troff
71 .if n \{\
72 .    ds #H 0
73 .    ds #V .8m
74 .    ds #F .3m
75 .    ds #[ \f1
76 .    ds #] \fP
77 .\}
78 .if t \{\
79 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80 .    ds #V .6m
81 .    ds #F 0
82 .    ds #[ \&
83 .    ds #] \&
84 .\}
85 .    \" simple accents for nroff and troff
86 .if n \{\
87 .    ds ' \&
88 .    ds ` \&
89 .    ds ^ \&
90 .    ds , \&
91 .    ds ~ ~
92 .    ds /
93 .\}
94 .if t \{\
95 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101 .\}
102 .    \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 .    \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 .    \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
117 \{\
118 .    ds : e
119 .    ds 8 ss
120 .    ds o a
121 .    ds d- d\h'-1'\(ga
122 .    ds D- D\h'-1'\(hy
123 .    ds th \o'bp'
124 .    ds Th \o'LP'
125 .    ds ae ae
126 .    ds Ae AE
127 .\}
128 .rm #[ #] #H #V #F C
129 .\" ========================================================================
130 .\"
131 .IX Title "Moose::Meta::TypeConstraint 3"
132 .TH Moose::Meta::TypeConstraint 3 "2009-11-19" "perl v5.8.7" "User Contributed Perl Documentation"
133 .SH "NAME"
134 Moose::Meta::TypeConstraint \- The Moose Type Constraint metaclass
135 .SH "DESCRIPTION"
136 .IX Header "DESCRIPTION"
137 This class represents a single type constraint. Moose's built-in type
138 constraints, as well as constraints you define, are all store in a
139 Moose::Meta::TypeConstraint::Registry object as objects of this
140 class.
141 .SH "INHERITANCE"
142 .IX Header "INHERITANCE"
143 \&\f(CW\*(C`Moose::Meta::TypeConstraint\*(C'\fR is a subclass of Class::MOP::Object.
144 .SH "METHODS"
145 .IX Header "METHODS"
146 .IP "\fBMoose::Meta::TypeConstraint\->new(%options)\fR" 4
147 .IX Item "Moose::Meta::TypeConstraint->new(%options)"
148 This creates a new type constraint based on the provided \f(CW%options\fR:
149 .RS 4
150 .IP "* name" 8
151 .IX Item "name"
152 The constraint name. If a name is not provided, it will be set to
153 \&\*(L"_\|_ANON_\|_\*(R".
154 .IP "* parent" 8
155 .IX Item "parent"
156 A \f(CW\*(C`Moose::Meta::TypeConstraint\*(C'\fR object which is the parent type for
157 the type being created. This is optional.
158 .IP "* constraint" 8
159 .IX Item "constraint"
160 This is the subroutine reference that implements the actual constraint
161 check. This defaults to a subroutine which always returns true.
162 .IP "* message" 8
163 .IX Item "message"
164 A subroutine reference which is used to generate an error message when
165 the constraint fails. This is optional.
166 .IP "* coercion" 8
167 .IX Item "coercion"
168 A Moose::Meta::TypeCoercion object representing the coercions to
169 the type. This is optional.
170 .IP "* optimized" 8
171 .IX Item "optimized"
172 This is a variant of the \f(CW\*(C`constraint\*(C'\fR parameter that is somehow
173 optimized. Typically, this means incorporating both the type's
174 constraint and all of its parents' constraints into a single
175 subroutine reference.
176 .RE
177 .RS 4
178 .RE
179 .IP "\fB$constraint\->equals($type_name_or_object)\fR" 4
180 .IX Item "$constraint->equals($type_name_or_object)"
181 Returns true if the supplied name or type object is the same as the
182 current type.
183 .IP "\fB$constraint\->is_subtype_of($type_name_or_object)\fR" 4
184 .IX Item "$constraint->is_subtype_of($type_name_or_object)"
185 Returns true if the supplied name or type object is a parent of the
186 current type.
187 .IP "\fB$constraint\->is_a_type_of($type_name_or_object)\fR" 4
188 .IX Item "$constraint->is_a_type_of($type_name_or_object)"
189 Returns true if the given type is the same as the current type, or is
190 a parent of the current type. This is a shortcut for checking
191 \&\f(CW\*(C`equals\*(C'\fR and \f(CW\*(C`is_subtype_of\*(C'\fR.
192 .IP "\fB$constraint\->coerce($value)\fR" 4
193 .IX Item "$constraint->coerce($value)"
194 This will attempt to coerce the value to the type. If the type does
195 have any defined coercions this will throw an error.
196 .IP "\fB$constraint\->check($value)\fR" 4
197 .IX Item "$constraint->check($value)"
198 Returns true if the given value passes the constraint for the type.
199 .IP "\fB$constraint\->validate($value)\fR" 4
200 .IX Item "$constraint->validate($value)"
201 This is similar to \f(CW\*(C`check\*(C'\fR. However, if the type \fIis valid\fR then the
202 method returns an explicit \f(CW\*(C`undef\*(C'\fR. If the type is not valid, we call
203 \&\f(CW\*(C`$self\->get_message($value)\*(C'\fR internally to generate an error
204 message.
205 .IP "\fB$constraint\->assert_valid($value)\fR" 4
206 .IX Item "$constraint->assert_valid($value)"
207 Like \f(CW\*(C`check\*(C'\fR and \f(CW\*(C`validate\*(C'\fR, this method checks whether \f(CW$value\fR is
208 valid under the constraint.  If it is, it will return true.  If it is not,
209 an exception will be thrown with the results of
210 \&\f(CW\*(C`$self\->get_message($value)\*(C'\fR.
211 .IP "\fB$constraint\->name\fR" 4
212 .IX Item "$constraint->name"
213 Returns the type's name, as provided to the constructor.
214 .IP "\fB$constraint\->parent\fR" 4
215 .IX Item "$constraint->parent"
216 Returns the type's parent, as provided to the constructor, if any.
217 .IP "\fB$constraint\->has_parent\fR" 4
218 .IX Item "$constraint->has_parent"
219 Returns true if the type has a parent type.
220 .IP "\fB$constraint\->parents\fR" 4
221 .IX Item "$constraint->parents"
222 A synonym for \f(CW\*(C`parent\*(C'\fR. This is useful for polymorphism with types
223 that can have more than one parent.
224 .IP "\fB$constraint\->constraint\fR" 4
225 .IX Item "$constraint->constraint"
226 Returns the type's constraint, as provided to the constructor.
227 .IP "\fB$constraint\->get_message($value)\fR" 4
228 .IX Item "$constraint->get_message($value)"
229 This generates a method for the given value. If the type does not have
230 an explicit message, we generate a default message.
231 .IP "\fB$constraint\->has_message\fR" 4
232 .IX Item "$constraint->has_message"
233 Returns true if the type has a message.
234 .IP "\fB$constraint\->message\fR" 4
235 .IX Item "$constraint->message"
236 Returns the type's message as a subroutine reference.
237 .IP "\fB$constraint\->coercion\fR" 4
238 .IX Item "$constraint->coercion"
239 Returns the type's Moose::Meta::TypeCoercion object, if one
240 exists.
241 .IP "\fB$constraint\->has_coercion\fR" 4
242 .IX Item "$constraint->has_coercion"
243 Returns true if the type has a coercion.
244 .IP "\fB$constraint\->hand_optimized_type_constraint\fR" 4
245 .IX Item "$constraint->hand_optimized_type_constraint"
246 Returns the type's hand optimized constraint, as provided to the
247 constructor via the \f(CW\*(C`optimized\*(C'\fR option.
248 .IP "\fB$constraint\->has_hand_optimized_type_constraint\fR" 4
249 .IX Item "$constraint->has_hand_optimized_type_constraint"
250 Returns true if the type has an optimized constraint.
251 .IP "\fB$constraint\->create_child_type(%options)\fR" 4
252 .IX Item "$constraint->create_child_type(%options)"
253 This returns a new type constraint of the same class using the
254 provided \f(CW%options\fR. The \f(CW\*(C`parent\*(C'\fR option will be the current type.
255 .Sp
256 This method exists so that subclasses of this class can override this
257 behavior and change how child types are created.
258 .SH "BUGS"
259 .IX Header "BUGS"
260 All complex software has bugs lurking in it, and this module is no
261 exception. If you find a bug please either email me, or add the bug
262 to cpan\-RT.
263 .SH "AUTHOR"
264 .IX Header "AUTHOR"
265 Stevan Little <stevan@iinteractive.com>
266 .SH "COPYRIGHT AND LICENSE"
267 .IX Header "COPYRIGHT AND LICENSE"
268 Copyright 2006\-2009 by Infinity Interactive, Inc.
269 .PP
270 <http://www.iinteractive.com>
271 .PP
272 This library is free software; you can redistribute it and/or modify
273 it under the same terms as Perl itself.