Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / Class::MOP::Attribute.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 "Class::MOP::Attribute 3"
132 .TH Class::MOP::Attribute 3 "2009-11-18" "perl v5.8.7" "User Contributed Perl Documentation"
133 .SH "NAME"
134 Class::MOP::Attribute \- Attribute Meta Object
135 .SH "SYNOPSIS"
136 .IX Header "SYNOPSIS"
137 .Vb 8
138 \&  Class::MOP::Attribute\->new(
139 \&      foo => (
140 \&          accessor  => 'foo',           # dual purpose get/set accessor
141 \&          predicate => 'has_foo',       # predicate check for defined\-ness
142 \&          init_arg  => '\-foo',          # class\->new will look for a \-foo key
143 \&          default   => 'BAR IS BAZ!'    # if no \-foo key is provided, use this
144 \&      )
145 \&  );
146 .Ve
147 .PP
148 .Vb 9
149 \&  Class::MOP::Attribute\->new(
150 \&      bar => (
151 \&          reader    => 'bar',           # getter
152 \&          writer    => 'set_bar',       # setter
153 \&          predicate => 'has_bar',       # predicate check for defined\-ness
154 \&          init_arg  => ':bar',          # class\->new will look for a :bar key
155 \&                                        # no default value means it is undef
156 \&      )
157 \&  );
158 .Ve
159 .SH "DESCRIPTION"
160 .IX Header "DESCRIPTION"
161 The Attribute Protocol is almost entirely an invention of
162 \&\f(CW\*(C`Class::MOP\*(C'\fR. Perl 5 does not have a consistent notion of
163 attributes. There are so many ways in which this is done, and very few
164 (if any) are easily discoverable by this module.
165 .PP
166 With that said, this module attempts to inject some order into this
167 chaos, by introducing a consistent \s-1API\s0 which can be used to create
168 object attributes.
169 .SH "METHODS"
170 .IX Header "METHODS"
171 .Sh "Creation"
172 .IX Subsection "Creation"
173 .IP "\fBClass::MOP::Attribute\->new($name, ?%options)\fR" 4
174 .IX Item "Class::MOP::Attribute->new($name, ?%options)"
175 An attribute must (at the very least), have a \f(CW$name\fR. All other
176 \&\f(CW%options\fR are added as key-value pairs.
177 .RS 4
178 .IP "* init_arg" 8
179 .IX Item "init_arg"
180 This is a string value representing the expected key in an
181 initialization hash. For instance, if we have an \f(CW\*(C`init_arg\*(C'\fR value of
182 \&\f(CW\*(C`\-foo\*(C'\fR, then the following code will Just Work.
183 .Sp
184 .Vb 1
185 \&  MyClass\->meta\->new_object( \-foo => 'Hello There' );
186 .Ve
187 .Sp
188 If an init_arg is not assigned, it will automatically use the
189 attribute's name. If \f(CW\*(C`init_arg\*(C'\fR is explicitly set to \f(CW\*(C`undef\*(C'\fR, the
190 attribute cannot be specified during initialization.
191 .IP "* builder" 8
192 .IX Item "builder"
193 This provides the name of a method that will be called to initialize
194 the attribute. This method will be called on the object after it is
195 constructed. It is expected to return a valid value for the attribute.
196 .IP "* default" 8
197 .IX Item "default"
198 This can be used to provide an explicit default for initializing the
199 attribute. If the default you provide is a subroutine reference, then
200 this reference will be called \fIas a method\fR on the object.
201 .Sp
202 If the value is a simple scalar (string or number), then it can be
203 just passed as is. However, if you wish to initialize it with a \s-1HASH\s0
204 or \s-1ARRAY\s0 ref, then you need to wrap that inside a subroutine
205 reference:
206 .Sp
207 .Vb 5
208 \&  Class::MOP::Attribute\->new(
209 \&      'foo' => (
210 \&          default => sub { [] },
211 \&      )
212 \&  );
213 .Ve
214 .Sp
215 .Vb 1
216 \&  # or ...
217 .Ve
218 .Sp
219 .Vb 5
220 \&  Class::MOP::Attribute\->new(
221 \&      'foo' => (
222 \&          default => sub { {} },
223 \&      )
224 \&  );
225 .Ve
226 .Sp
227 If you wish to initialize an attribute with a subroutine reference
228 itself, then you need to wrap that in a subroutine as well:
229 .Sp
230 .Vb 7
231 \&  Class::MOP::Attribute\->new(
232 \&      'foo' => (
233 \&          default => sub {
234 \&              sub { print "Hello World" }
235 \&          },
236 \&      )
237 \&  );
238 .Ve
239 .Sp
240 And lastly, if the value of your attribute is dependent upon some
241 other aspect of the instance structure, then you can take advantage of
242 the fact that when the \f(CW\*(C`default\*(C'\fR value is called as a method:
243 .Sp
244 .Vb 5
245 \&  Class::MOP::Attribute\->new(
246 \&      'object_identity' => (
247 \&          default => sub { Scalar::Util::refaddr( $_[0] ) },
248 \&      )
249 \&  );
250 .Ve
251 .Sp
252 Note that there is no guarantee that attributes are initialized in any
253 particular order, so you cannot rely on the value of some other
254 attribute when generating the default.
255 .IP "* initializer" 8
256 .IX Item "initializer"
257 This option can be either a method name or a subroutine
258 reference. This method will be called when setting the attribute's
259 value in the constructor. Unlike \f(CW\*(C`default\*(C'\fR and \f(CW\*(C`builder\*(C'\fR, the
260 initializer is only called when a value is provided to the
261 constructor. The initializer allows you to munge this value during
262 object construction.
263 .Sp
264 The initializer is called as a method with three arguments. The first
265 is the value that was passed to the constructor. The second is a
266 subroutine reference that can be called to actually set the
267 attribute's value, and the last is the associated
268 \&\f(CW\*(C`Class::MOP::Attribute\*(C'\fR object.
269 .Sp
270 This contrived example shows an initializer that sets the attribute to
271 twice the given value.
272 .Sp
273 .Vb 8
274 \&  Class::MOP::Attribute\->new(
275 \&      'doubled' => (
276 \&          initializer => sub {
277 \&              my ( $self, $value, $set, $attr ) = @_;
278 \&              $set\->( $value * 2 );
279 \&          },
280 \&      )
281 \&  );
282 .Ve
283 .Sp
284 Since an initializer can be a method name, you can easily make
285 attribute initialization use the writer:
286 .Sp
287 .Vb 6
288 \&  Class::MOP::Attribute\->new(
289 \&      'some_attr' => (
290 \&          writer      => 'some_attr',
291 \&          initializer => 'some_attr',
292 \&      )
293 \&  );
294 .Ve
295 .Sp
296 Your writer will need to examine \f(CW@_\fR and determine under which
297 context it is being called.
298 .RE
299 .RS 4
300 .Sp
301 The \f(CW\*(C`accessor\*(C'\fR, \f(CW\*(C`reader\*(C'\fR, \f(CW\*(C`writer\*(C'\fR, \f(CW\*(C`predicate\*(C'\fR and \f(CW\*(C`clearer\*(C'\fR
302 options all accept the same parameters. You can provide the name of
303 the method, in which case an appropriate default method will be
304 generated for you. Or instead you can also provide hash reference
305 containing exactly one key (the method name) and one value. The value
306 should be a subroutine reference, which will be installed as the
307 method itself.
308 .IP "* accessor" 8
309 .IX Item "accessor"
310 An \f(CW\*(C`accessor\*(C'\fR is a standard Perl-style read/write accessor. It will
311 return the value of the attribute, and if a value is passed as an
312 argument, it will assign that value to the attribute.
313 .Sp
314 Note that \f(CW\*(C`undef\*(C'\fR is a legitimate value, so this will work:
315 .Sp
316 .Vb 1
317 \&  $object\->set_something(undef);
318 .Ve
319 .IP "* reader" 8
320 .IX Item "reader"
321 This is a basic read-only accessor. It returns the value of the
322 attribute.
323 .IP "* writer" 8
324 .IX Item "writer"
325 This is a basic write accessor, it accepts a single argument, and
326 assigns that value to the attribute.
327 .Sp
328 Note that \f(CW\*(C`undef\*(C'\fR is a legitimate value, so this will work:
329 .Sp
330 .Vb 1
331 \&  $object\->set_something(undef);
332 .Ve
333 .IP "* predicate" 8
334 .IX Item "predicate"
335 The predicate method returns a boolean indicating whether or not the
336 attribute has been explicitly set.
337 .Sp
338 Note that the predicate returns true even if the attribute was set to
339 a false value (\f(CW0\fR or \f(CW\*(C`undef\*(C'\fR).
340 .IP "* clearer" 8
341 .IX Item "clearer"
342 This method will uninitialize the attribute. After an attribute is
343 cleared, its \f(CW\*(C`predicate\*(C'\fR will return false.
344 .IP "* definition_context" 8
345 .IX Item "definition_context"
346 Mostly, this exists as a hook for the benefit of Moose.
347 .Sp
348 This option should be a hash reference containing several keys which
349 will be used when inlining the attribute's accessors. The keys should
350 include \f(CW\*(C`line\*(C'\fR, the line number where the attribute was created, and
351 either \f(CW\*(C`file\*(C'\fR or \f(CW\*(C`description\*(C'\fR.
352 .Sp
353 This information will ultimately be used when eval'ing inlined
354 accessor code so that error messages report a useful line and file
355 name.
356 .RE
357 .RS 4
358 .RE
359 .IP "\fB$attr\->clone(%options)\fR" 4
360 .IX Item "$attr->clone(%options)"
361 This clones the attribute. Any options you provide will override the
362 settings of the original attribute. You can change the name of the new
363 attribute by passing a \f(CW\*(C`name\*(C'\fR key in \f(CW%options\fR.
364 .Sh "Informational"
365 .IX Subsection "Informational"
366 These are all basic read-only accessors for the values passed into
367 the constructor.
368 .IP "\fB$attr\->name\fR" 4
369 .IX Item "$attr->name"
370 Returns the attribute's name.
371 .IP "\fB$attr\->accessor\fR" 4
372 .IX Item "$attr->accessor"
373 .PD 0
374 .IP "\fB$attr\->reader\fR" 4
375 .IX Item "$attr->reader"
376 .IP "\fB$attr\->writer\fR" 4
377 .IX Item "$attr->writer"
378 .IP "\fB$attr\->predicate\fR" 4
379 .IX Item "$attr->predicate"
380 .IP "\fB$attr\->clearer\fR" 4
381 .IX Item "$attr->clearer"
382 .PD
383 The \f(CW\*(C`accessor\*(C'\fR, \f(CW\*(C`reader\*(C'\fR, \f(CW\*(C`writer\*(C'\fR, \f(CW\*(C`predicate\*(C'\fR, and \f(CW\*(C`clearer\*(C'\fR
384 methods all return exactly what was passed to the constructor, so it
385 can be either a string containing a method name, or a hash reference.
386 .IP "\fB$attr\->initializer\fR" 4
387 .IX Item "$attr->initializer"
388 Returns the initializer as passed to the constructor, so this may be
389 either a method name or a subroutine reference.
390 .IP "\fB$attr\->init_arg\fR" 4
391 .IX Item "$attr->init_arg"
392 .PD 0
393 .IP "\fB$attr\->is_default_a_coderef\fR" 4
394 .IX Item "$attr->is_default_a_coderef"
395 .IP "\fB$attr\->default($instance)\fR" 4
396 .IX Item "$attr->default($instance)"
397 .PD
398 The \f(CW$instance\fR argument is optional. If you don't pass it, the
399 return value for this method is exactly what was passed to the
400 constructor, either a simple scalar or a subroutine reference.
401 .Sp
402 If you \fIdo\fR pass an \f(CW$instance\fR and the default is a subroutine
403 reference, then the reference is called as a method on the
404 \&\f(CW$instance\fR and the generated value is returned.
405 .IP "\fB$attr\->slots\fR" 4
406 .IX Item "$attr->slots"
407 Return a list of slots required by the attribute. This is usually just
408 one, the name of the attribute.
409 .Sp
410 A slot is the name of the hash key used to store the attribute in an
411 object instance.
412 .IP "\fB$attr\->get_read_method\fR" 4
413 .IX Item "$attr->get_read_method"
414 .PD 0
415 .IP "\fB$attr\->get_write_method\fR" 4
416 .IX Item "$attr->get_write_method"
417 .PD
418 Returns the name of a method suitable for reading or writing the value
419 of the attribute in the associated class.
420 .Sp
421 If an attribute is read\- or write\-only, then these methods can return
422 \&\f(CW\*(C`undef\*(C'\fR as appropriate.
423 .IP "\fB$attr\->has_read_method\fR" 4
424 .IX Item "$attr->has_read_method"
425 .PD 0
426 .IP "\fB$attr\->has_write_method\fR" 4
427 .IX Item "$attr->has_write_method"
428 .PD
429 This returns a boolean indicating whether the attribute has a \fInamed\fR
430 read or write method.
431 .IP "\fB$attr\->get_read_method_ref\fR" 4
432 .IX Item "$attr->get_read_method_ref"
433 .PD 0
434 .IP "\fB$attr\->get_write_method_ref\fR" 4
435 .IX Item "$attr->get_write_method_ref"
436 .PD
437 Returns the subroutine reference of a method suitable for reading or
438 writing the attribute's value in the associated class. These methods
439 always return a subroutine reference, regardless of whether or not the
440 attribute is read\- or write\-only.
441 .IP "\fB$attr\->insertion_order\fR" 4
442 .IX Item "$attr->insertion_order"
443 If this attribute has been inserted into a class, this returns a zero
444 based index regarding the order of insertion.
445 .Sh "Informational predicates"
446 .IX Subsection "Informational predicates"
447 These are all basic predicate methods for the values passed into \f(CW\*(C`new\*(C'\fR.
448 .IP "\fB$attr\->has_accessor\fR" 4
449 .IX Item "$attr->has_accessor"
450 .PD 0
451 .IP "\fB$attr\->has_reader\fR" 4
452 .IX Item "$attr->has_reader"
453 .IP "\fB$attr\->has_writer\fR" 4
454 .IX Item "$attr->has_writer"
455 .IP "\fB$attr\->has_predicate\fR" 4
456 .IX Item "$attr->has_predicate"
457 .IP "\fB$attr\->has_clearer\fR" 4
458 .IX Item "$attr->has_clearer"
459 .IP "\fB$attr\->has_initializer\fR" 4
460 .IX Item "$attr->has_initializer"
461 .IP "\fB$attr\->has_init_arg\fR" 4
462 .IX Item "$attr->has_init_arg"
463 .PD
464 This will be \fIfalse\fR if the \f(CW\*(C`init_arg\*(C'\fR was set to \f(CW\*(C`undef\*(C'\fR.
465 .IP "\fB$attr\->has_default\fR" 4
466 .IX Item "$attr->has_default"
467 This will be \fIfalse\fR if the \f(CW\*(C`default\*(C'\fR was set to \f(CW\*(C`undef\*(C'\fR, since
468 \&\f(CW\*(C`undef\*(C'\fR is the default \f(CW\*(C`default\*(C'\fR anyway.
469 .IP "\fB$attr\->has_builder\fR" 4
470 .IX Item "$attr->has_builder"
471 .PD 0
472 .IP "\fB$attr\->has_insertion_order\fR" 4
473 .IX Item "$attr->has_insertion_order"
474 .PD
475 This will be \fIfalse\fR if this attribute has not be inserted into a class
476 .Sh "Value management"
477 .IX Subsection "Value management"
478 These methods are basically \*(L"back doors\*(R" to the instance, and can be
479 used to bypass the regular accessors, but still stay within the \s-1MOP\s0.
480 .PP
481 These methods are not for general use, and should only be used if you
482 really know what you are doing.
483 .ie n .IP "\fB$attr\->initialize_instance_slot($meta_instance, \fB$instance\fB, \f(BI$params\fB)\fR" 4
484 .el .IP "\fB$attr\->initialize_instance_slot($meta_instance, \f(CB$instance\fB, \f(CB$params\fB)\fR" 4
485 .IX Item "$attr->initialize_instance_slot($meta_instance, $instance, $params)"
486 This method is used internally to initialize the attribute's slot in
487 the object \f(CW$instance\fR.
488 .Sp
489 The \f(CW$params\fR is a hash reference of the values passed to the object
490 constructor.
491 .Sp
492 It's unlikely that you'll need to call this method yourself.
493 .ie n .IP "\fB$attr\->set_value($instance, \fB$value\fB)\fR" 4
494 .el .IP "\fB$attr\->set_value($instance, \f(CB$value\fB)\fR" 4
495 .IX Item "$attr->set_value($instance, $value)"
496 Sets the value without going through the accessor. Note that this
497 works even with read-only attributes.
498 .ie n .IP "\fB$attr\->set_raw_value($instance, \fB$value\fB)\fR" 4
499 .el .IP "\fB$attr\->set_raw_value($instance, \f(CB$value\fB)\fR" 4
500 .IX Item "$attr->set_raw_value($instance, $value)"
501 Sets the value with no side effects such as a trigger.
502 .Sp
503 This doesn't actually apply to Class::MOP attributes, only to subclasses.
504 .ie n .IP "\fB$attr\->set_initial_value($instance, \fB$value\fB)\fR" 4
505 .el .IP "\fB$attr\->set_initial_value($instance, \f(CB$value\fB)\fR" 4
506 .IX Item "$attr->set_initial_value($instance, $value)"
507 Sets the value without going through the accessor. This method is only
508 called when the instance is first being initialized.
509 .IP "\fB$attr\->get_value($instance)\fR" 4
510 .IX Item "$attr->get_value($instance)"
511 Returns the value without going through the accessor. Note that this
512 works even with write-only accessors.
513 .IP "\fB$sttr\->get_raw_value($instance)\fR" 4
514 .IX Item "$sttr->get_raw_value($instance)"
515 Returns the value without any side effects such as lazy attributes.
516 .Sp
517 Doesn't actually apply to Class::MOP attributes, only to subclasses.
518 .IP "\fB$attr\->has_value($instance)\fR" 4
519 .IX Item "$attr->has_value($instance)"
520 Return a boolean indicating whether the attribute has been set in
521 \&\f(CW$instance\fR. This how the default \f(CW\*(C`predicate\*(C'\fR method works.
522 .IP "\fB$attr\->clear_value($instance)\fR" 4
523 .IX Item "$attr->clear_value($instance)"
524 This will clear the attribute's value in \f(CW$instance\fR. This is what
525 the default \f(CW\*(C`clearer\*(C'\fR calls.
526 .Sp
527 Note that this works even if the attribute does not have any
528 associated read, write or clear methods.
529 .Sh "Class association"
530 .IX Subsection "Class association"
531 These methods allow you to manage the attributes association with
532 the class that contains it. These methods should not be used
533 lightly, nor are they very magical, they are mostly used internally
534 and by metaclass instances.
535 .IP "\fB$attr\->associated_class\fR" 4
536 .IX Item "$attr->associated_class"
537 This returns the \f(CW\*(C`Class::MOP::Class\*(C'\fR with which this attribute is
538 associated, if any.
539 .IP "\fB$attr\->attach_to_class($metaclass)\fR" 4
540 .IX Item "$attr->attach_to_class($metaclass)"
541 This method stores a weakened reference to the \f(CW$metaclass\fR object
542 internally.
543 .Sp
544 This method does not remove the attribute from its old class,
545 nor does it create any accessors in the new class.
546 .Sp
547 It is probably best to use the Class::MOP::Class \f(CW\*(C`add_attribute\*(C'\fR
548 method instead.
549 .IP "\fB$attr\->detach_from_class\fR" 4
550 .IX Item "$attr->detach_from_class"
551 This method removes the associate metaclass object from the attribute
552 it has one.
553 .Sp
554 This method does not remove the attribute itself from the class, or
555 remove its accessors.
556 .Sp
557 It is probably best to use the Class::MOP::Class
558 \&\f(CW\*(C`remove_attribute\*(C'\fR method instead.
559 .Sh "Attribute Accessor generation"
560 .IX Subsection "Attribute Accessor generation"
561 .IP "\fB$attr\->accessor_metaclass\fR" 4
562 .IX Item "$attr->accessor_metaclass"
563 Accessor methods are generated using an accessor metaclass. By
564 default, this is Class::MOP::Method::Accessor. This method returns
565 the name of the accessor metaclass that this attribute uses.
566 .IP "\fB$attr\->associate_method($method)\fR" 4
567 .IX Item "$attr->associate_method($method)"
568 This associates a Class::MOP::Method object with the
569 attribute. Typically, this is called internally when an attribute
570 generates its accessors.
571 .IP "\fB$attr\->associated_methods\fR" 4
572 .IX Item "$attr->associated_methods"
573 This returns the list of methods which have been associated with the
574 attribute.
575 .IP "\fB$attr\->install_accessors\fR" 4
576 .IX Item "$attr->install_accessors"
577 This method generates and installs code the attributes various
578 accessors. It is typically called from the Class::MOP::Class
579 \&\f(CW\*(C`add_attribute\*(C'\fR method.
580 .IP "\fB$attr\->remove_accessors\fR" 4
581 .IX Item "$attr->remove_accessors"
582 This method removes all of the accessors associated with the
583 attribute.
584 .Sp
585 This does not currently remove methods from the list returned by
586 \&\f(CW\*(C`associated_methods\*(C'\fR.
587 .Sh "Introspection"
588 .IX Subsection "Introspection"
589 .IP "\fBClass::MOP::Attribute\->meta\fR" 4
590 .IX Item "Class::MOP::Attribute->meta"
591 This will return a Class::MOP::Class instance for this class.
592 .Sp
593 It should also be noted that Class::MOP will actually bootstrap
594 this module by installing a number of attribute meta-objects into its
595 metaclass.
596 .SH "AUTHORS"
597 .IX Header "AUTHORS"
598 Stevan Little <stevan@iinteractive.com>
599 .SH "COPYRIGHT AND LICENSE"
600 .IX Header "COPYRIGHT AND LICENSE"
601 Copyright 2006\-2009 by Infinity Interactive, Inc.
602 .PP
603 <http://www.iinteractive.com>
604 .PP
605 This library is free software; you can redistribute it and/or modify
606 it under the same terms as Perl itself.