Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / Moose::Meta::Attribute::Native.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::Attribute::Native 3"
132 .TH Moose::Meta::Attribute::Native 3 "2009-11-19" "perl v5.8.7" "User Contributed Perl Documentation"
133 .SH "NAME"
134 Moose::Meta::Attribute::Native \- Extend your attribute interfaces
135 .SH "SYNOPSIS"
136 .IX Header "SYNOPSIS"
137 .Vb 2
138 \&  package MyClass;
139 \&  use Moose;
140 .Ve
141 .PP
142 .Vb 13
143 \&  has 'mapping' => (
144 \&      traits    => [ 'Hash' ],
145 \&      is        => 'rw',
146 \&      isa       => 'HashRef[Str]',
147 \&      default   => sub { {} },
148 \&      handles   => {
149 \&          exists_in_mapping => 'exists',
150 \&          ids_in_mapping    => 'keys',
151 \&          get_mapping       => 'get',
152 \&          set_mapping       => 'set',
153 \&          set_quantity      => [ set => 'quantity' ],
154 \&      },
155 \&  );
156 .Ve
157 .PP
158 .Vb 1
159 \&  # ...
160 .Ve
161 .PP
162 .Vb 5
163 \&  my $obj = MyClass\->new;
164 \&  $obj\->set_quantity(10);      # quantity => 10
165 \&  $obj\->set_mapping('foo', 4); # foo => 4
166 \&  $obj\->set_mapping('bar', 5); # bar => 5
167 \&  $obj\->set_mapping('baz', 6); # baz => 6
168 .Ve
169 .PP
170 .Vb 2
171 \&  # prints 5
172 \&  print $obj\->get_mapping('bar') if $obj\->exists_in_mapping('bar');
173 .Ve
174 .PP
175 .Vb 2
176 \&  # prints 'quantity, foo, bar, baz'
177 \&  print join ', ', $obj\->ids_in_mapping;
178 .Ve
179 .SH "DESCRIPTION"
180 .IX Header "DESCRIPTION"
181 While Moose attributes provide a way to name your accessors, readers,
182 writers, clearers and predicates, this set of traits provides commonly
183 used attribute helper methods for more specific types of data.
184 .PP
185 As seen in the \*(L"\s-1SYNOPSIS\s0\*(R", you specify the data structure via the
186 \&\f(CW\*(C`trait\*(C'\fR parameter. Available traits are below; see \*(L"\s-1METHOD\s0 \s-1PROVIDERS\s0\*(R".
187 .PP
188 This module used to exist as the MooseX::AttributeHelpers extension. It was
189 very commonly used, so we moved it into core Moose. Since this gave us a chance
190 to change the interface, you will have to change your code or continue using
191 the MooseX::AttributeHelpers extension. MooseX::AttributeHelpers should
192 continue to work.
193 .SH "PARAMETERS"
194 .IX Header "PARAMETERS"
195 .Sh "handles"
196 .IX Subsection "handles"
197 This is like \f(CW\*(C`handles\*(C'\fR in \*(L"has\*(R" in Moose, but only \s-1HASH\s0 references are
198 allowed.  Keys are method names that you want installed locally, and values are
199 methods from the method providers (below).  Currying with delegated methods
200 works normally for \f(CW\*(C`handles\*(C'\fR.
201 .SH "METHOD PROVIDERS"
202 .IX Header "METHOD PROVIDERS"
203 .IP "Number" 4
204 .IX Item "Number"
205 Common numerical operations.
206 .Sp
207 .Vb 15
208 \&    has 'integer' => (
209 \&        traits    => ['Number'],
210 \&        is        => 'ro',
211 \&        isa       => 'Int',
212 \&        default   => 5,
213 \&        handles   => {
214 \&            set => 'set',
215 \&            add => 'add',
216 \&            sub => 'sub',
217 \&            mul => 'mul',
218 \&            div => 'div',
219 \&            mod => 'mod',
220 \&            abs => 'abs',
221 \&        }
222 \&    );
223 .Ve
224 .IP "String" 4
225 .IX Item "String"
226 Common methods for string operations.
227 .Sp
228 .Vb 10
229 \&    has 'text' => (
230 \&        traits    => ['String'],
231 \&        is        => 'rw',
232 \&        isa       => 'Str',
233 \&        default   => q{},
234 \&        handles   => {
235 \&            add_text     => 'append',
236 \&            replace_text => 'replace',
237 \&        }
238 \&    );
239 .Ve
240 .IP "Counter" 4
241 .IX Item "Counter"
242 Methods for incrementing and decrementing a counter attribute.
243 .Sp
244 .Vb 11
245 \&    has 'counter' => (
246 \&        traits    => ['Counter'],
247 \&        is        => 'ro',
248 \&        isa       => 'Num',
249 \&        default   => 0,
250 \&        handles   => {
251 \&            inc_counter   => 'inc',
252 \&            dec_counter   => 'dec',
253 \&            reset_counter => 'reset',
254 \&        }
255 \&    );
256 .Ve
257 .IP "Bool" 4
258 .IX Item "Bool"
259 Common methods for boolean values.
260 .Sp
261 .Vb 12
262 \&    has 'is_lit' => (
263 \&        traits    => ['Bool'],
264 \&        is        => 'rw',
265 \&        isa       => 'Bool',
266 \&        default   => 0,
267 \&        handles   => {
268 \&            illuminate  => 'set',
269 \&            darken      => 'unset',
270 \&            flip_switch => 'toggle',
271 \&            is_dark     => 'not',
272 \&        }
273 \&    );
274 .Ve
275 .IP "Hash" 4
276 .IX Item "Hash"
277 Common methods for hash references.
278 .Sp
279 .Vb 11
280 \&    has 'options' => (
281 \&        traits    => ['Hash'],
282 \&        is        => 'ro',
283 \&        isa       => 'HashRef[Str]',
284 \&        default   => sub { {} },
285 \&        handles   => {
286 \&            set_option => 'set',
287 \&            get_option => 'get',
288 \&            has_option => 'exists',
289 \&        }
290 \&    );
291 .Ve
292 .IP "Array" 4
293 .IX Item "Array"
294 Common methods for array references.
295 .Sp
296 .Vb 10
297 \&    has 'queue' => (
298 \&       traits     => ['Array'],
299 \&       is         => 'ro',
300 \&       isa        => 'ArrayRef[Str]',
301 \&       default    => sub { [] },
302 \&       handles    => {
303 \&           add_item  => 'push',
304 \&           next_item => 'shift',
305 \&       }
306 \&    );
307 .Ve
308 .IP "Code" 4
309 .IX Item "Code"
310 Common methods for code references.
311 .Sp
312 .Vb 9
313 \&    has 'callback' => (
314 \&       traits     => ['Code'],
315 \&       is         => 'ro',
316 \&       isa        => 'CodeRef',
317 \&       default    => sub { sub { 'called' } },
318 \&       handles    => {
319 \&           call => 'execute',
320 \&       }
321 \&    );
322 .Ve
323 .SH "BUGS"
324 .IX Header "BUGS"
325 All complex software has bugs lurking in it, and this module is no
326 exception. If you find a bug please either email me, or add the bug
327 to cpan\-RT.
328 .SH "AUTHOR"
329 .IX Header "AUTHOR"
330 Stevan Little <stevan@iinteractive.com>
331 .PP
332 \&\fBwith contributions from:\fR
333 .PP
334 Robert (rlb3) Boone
335 .PP
336 Paul (frodwith) Driver
337 .PP
338 Shawn (Sartak) Moore
339 .PP
340 Chris (perigrin) Prather
341 .PP
342 Robert (phaylon) Sedlacek
343 .PP
344 Tom (dec) Lanyon
345 .PP
346 Yuval Kogman
347 .PP
348 Jason May
349 .PP
350 Cory (gphat) Watson
351 .PP
352 Florian (rafl) Ragwitz
353 .PP
354 Evan Carroll
355 .PP
356 Jesse (doy) Luehrs
357 .SH "COPYRIGHT AND LICENSE"
358 .IX Header "COPYRIGHT AND LICENSE"
359 Copyright 2007\-2009 by Infinity Interactive, Inc.
360 .PP
361 <http://www.iinteractive.com>
362 .PP
363 This library is free software; you can redistribute it and/or modify
364 it under the same terms as Perl itself.