bunch of doc fixes
[gitmo/Class-MOP.git] / lib / Class / MOP / Attribute.pm
1
2 package Class::MOP::Attribute;
3
4 use strict;
5 use warnings;
6
7 use Class::MOP::Method::Accessor;
8
9 use Carp         'confess';
10 use Scalar::Util 'blessed', 'reftype', 'weaken';
11
12 our $VERSION   = '0.23';
13 our $AUTHORITY = 'cpan:STEVAN';
14
15 use base 'Class::MOP::Object';
16
17 sub meta {
18     require Class::MOP::Class;
19     Class::MOP::Class->initialize(blessed($_[0]) || $_[0]);
20 }
21
22 # NOTE: (meta-circularity)
23 # This method will be replaced in the
24 # boostrap section of Class::MOP, by
25 # a new version which uses the
26 # &Class::MOP::Class::construct_instance
27 # method to build an attribute meta-object
28 # which itself is described with attribute
29 # meta-objects.
30 #     - Ain't meta-circularity grand? :)
31 sub new {
32     my $class   = shift;
33     my $name    = shift;
34     my %options = @_;
35
36     (defined $name && $name)
37         || confess "You must provide a name for the attribute";
38
39     $options{init_arg} = $name
40         if not exists $options{init_arg};
41     if(exists $options{builder}){
42         confess("builder must be a defined scalar value which is a method name")
43             if ref $options{builder} || !(defined $options{builder});
44         confess("Setting both default and builder is not allowed.")
45             if exists $options{default};
46     } else {
47         (is_default_a_coderef(\%options))
48             || confess("References are not allowed as default values, you must ".
49                        "wrap then in a CODE reference (ex: sub { [] } and not [])")
50                 if exists $options{default} && ref $options{default};
51     }
52     if( $options{required} and not( defined($options{builder}) || defined($options{init_arg}) || exists $options{default} ) ) {
53         confess("A required attribute must have either 'init_arg', 'builder', or 'default'");
54     }
55     bless {
56         '$!name'      => $name,
57         '$!accessor'  => $options{accessor},
58         '$!reader'    => $options{reader},
59         '$!writer'      => $options{writer},
60         '$!predicate'   => $options{predicate},
61         '$!clearer'     => $options{clearer},
62         '$!builder'     => $options{builder},
63         '$!init_arg'    => $options{init_arg},
64         '$!default'     => $options{default},
65         '$!initializer' => $options{initializer},        
66         # keep a weakened link to the
67         # class we are associated with
68         '$!associated_class' => undef,
69         # and a list of the methods
70         # associated with this attr
71         '@!associated_methods' => [],
72         # NOTE:
73         # protect this from silliness
74         init_arg => undef,
75     } => $class;
76 }
77
78 # NOTE:
79 # this is a primative (and kludgy) clone operation
80 # for now, it will be replaced in the Class::MOP
81 # bootstrap with a proper one, however we know
82 # that this one will work fine for now.
83 sub clone {
84     my $self    = shift;
85     my %options = @_;
86     (blessed($self))
87         || confess "Can only clone an instance";
88     return bless { %{$self}, %options } => blessed($self);
89 }
90
91 sub initialize_instance_slot {
92     my ($self, $meta_instance, $instance, $params) = @_;
93     my $init_arg = $self->{'$!init_arg'};
94     # try to fetch the init arg from the %params ...
95
96     # if nothing was in the %params, we can use the
97     # attribute's default value (if it has one)
98     if(defined $init_arg and exists $params->{$init_arg}){
99         $self->_set_initial_slot_value(
100             $meta_instance, 
101             $instance,
102             $params->{$init_arg},
103         );
104     } 
105     elsif (defined $self->{'$!default'}) {
106         $self->_set_initial_slot_value(
107             $meta_instance, 
108             $instance,
109             $self->default($instance),
110         );
111     } 
112     elsif (defined( my $builder = $self->{'$!builder'})) {
113         if ($builder = $instance->can($builder)) {
114             $self->_set_initial_slot_value(
115                 $meta_instance, 
116                 $instance,
117                 $instance->$builder,
118             );
119         } 
120         else {
121             confess(blessed($instance)." does not support builder method '". $self->{'$!builder'} ."' for attribute '" . $self->name . "'");
122         }
123     }
124 }
125
126 sub _set_initial_slot_value {
127     my ($self, $meta_instance, $instance, $value) = @_;
128
129     my $slot_name = $self->name;
130
131     return $meta_instance->set_slot_value($instance, $slot_name, $value)
132         unless $self->has_initializer;
133
134     my $callback = sub {
135         $meta_instance->set_slot_value($instance, $slot_name, $_[0]);
136     };
137     
138     my $initializer = $self->initializer;
139
140     # most things will just want to set a value, so make it first arg
141     $instance->$initializer($value, $callback, $self);
142 }
143
144 # NOTE:
145 # the next bunch of methods will get bootstrapped
146 # away in the Class::MOP bootstrapping section
147
148 sub name { $_[0]->{'$!name'} }
149
150 sub associated_class   { $_[0]->{'$!associated_class'}   }
151 sub associated_methods { $_[0]->{'@!associated_methods'} }
152
153 sub has_accessor    { defined($_[0]->{'$!accessor'})     ? 1 : 0 }
154 sub has_reader      { defined($_[0]->{'$!reader'})       ? 1 : 0 }
155 sub has_writer      { defined($_[0]->{'$!writer'})       ? 1 : 0 }
156 sub has_predicate   { defined($_[0]->{'$!predicate'})    ? 1 : 0 }
157 sub has_clearer     { defined($_[0]->{'$!clearer'})      ? 1 : 0 }
158 sub has_builder     { defined($_[0]->{'$!builder'})      ? 1 : 0 }
159 sub has_init_arg    { defined($_[0]->{'$!init_arg'})     ? 1 : 0 }
160 sub has_default     { defined($_[0]->{'$!default'})      ? 1 : 0 }
161 sub has_initializer { defined($_[0]->{'$!initializer'})  ? 1 : 0 }
162
163 sub accessor    { $_[0]->{'$!accessor'}    }
164 sub reader      { $_[0]->{'$!reader'}      }
165 sub writer      { $_[0]->{'$!writer'}      }
166 sub predicate   { $_[0]->{'$!predicate'}   }
167 sub clearer     { $_[0]->{'$!clearer'}     }
168 sub builder     { $_[0]->{'$!builder'}     }
169 sub init_arg    { $_[0]->{'$!init_arg'}    }
170 sub initializer { $_[0]->{'$!initializer'} }
171
172 # end bootstrapped away method section.
173 # (all methods below here are kept intact)
174
175 sub get_read_method  { 
176     my $self   = shift;    
177     my $reader = $self->reader || $self->accessor;
178     # normal case ...
179     return $reader unless ref $reader;
180     # the HASH ref case
181     my ($name) = %$reader;
182     return $name;
183 }
184
185 sub get_write_method { 
186     my $self   = shift;
187     my $writer = $self->writer || $self->accessor; 
188     # normal case ...
189     return $writer unless ref $writer;
190     # the HASH ref case
191     my ($name) = %$writer;
192     return $name;    
193 }
194
195 sub get_read_method_ref {
196     my $self = shift;
197     if ((my $reader = $self->get_read_method) && $self->associated_class) {   
198         return $self->associated_class->get_method($reader);
199     }
200     else {
201         return sub { $self->get_value(@_) };
202     }
203 }
204
205 sub get_write_method_ref {
206     my $self = shift;    
207     if ((my $writer = $self->get_write_method) && $self->associated_class) {         
208         return $self->associated_class->get_method($writer);
209     }
210     else {
211         return sub { $self->set_value(@_) };
212     }
213 }
214
215 sub is_default_a_coderef {
216     ('CODE' eq (reftype($_[0]->{'$!default'} || $_[0]->{default}) || ''))
217 }
218
219 sub default {
220     my ($self, $instance) = @_;
221     if (defined $instance && $self->is_default_a_coderef) {
222         # if the default is a CODE ref, then
223         # we pass in the instance and default
224         # can return a value based on that
225         # instance. Somewhat crude, but works.
226         return $self->{'$!default'}->($instance);
227     }
228     $self->{'$!default'};
229 }
230
231 # slots
232
233 sub slots { (shift)->name }
234
235 # class association
236
237 sub attach_to_class {
238     my ($self, $class) = @_;
239     (blessed($class) && $class->isa('Class::MOP::Class'))
240         || confess "You must pass a Class::MOP::Class instance (or a subclass)";
241     weaken($self->{'$!associated_class'} = $class);
242 }
243
244 sub detach_from_class {
245     my $self = shift;
246     $self->{'$!associated_class'} = undef;
247 }
248
249 # method association
250
251 sub associate_method {
252     my ($self, $method) = @_;
253     push @{$self->{'@!associated_methods'}} => $method;
254 }
255
256 ## Slot management
257
258 sub set_initial_value {
259     my ($self, $instance, $value) = @_;
260     $self->_set_initial_slot_value(
261         Class::MOP::Class->initialize(blessed($instance))->get_meta_instance,
262         $instance,
263         $value
264     );
265 }
266
267 sub set_value {
268     my ($self, $instance, $value) = @_;
269
270     Class::MOP::Class->initialize(blessed($instance))
271                      ->get_meta_instance
272                      ->set_slot_value($instance, $self->name, $value);
273 }
274
275 sub get_value {
276     my ($self, $instance) = @_;
277
278     Class::MOP::Class->initialize(blessed($instance))
279                      ->get_meta_instance
280                      ->get_slot_value($instance, $self->name);
281 }
282
283 sub has_value {
284     my ($self, $instance) = @_;
285
286     Class::MOP::Class->initialize(blessed($instance))
287                      ->get_meta_instance
288                      ->is_slot_initialized($instance, $self->name);
289 }
290
291 sub clear_value {
292     my ($self, $instance) = @_;
293
294     Class::MOP::Class->initialize(blessed($instance))
295                      ->get_meta_instance
296                      ->deinitialize_slot($instance, $self->name);
297 }
298
299 ## load em up ...
300
301 sub accessor_metaclass { 'Class::MOP::Method::Accessor' }
302
303 sub process_accessors {
304     my ($self, $type, $accessor, $generate_as_inline_methods) = @_;
305     if (reftype($accessor)) {
306         (reftype($accessor) eq 'HASH')
307             || confess "bad accessor/reader/writer/predicate/clearer format, must be a HASH ref";
308         my ($name, $method) = %{$accessor};
309         $method = $self->accessor_metaclass->wrap($method);
310         $self->associate_method($method);
311         return ($name, $method);
312     }
313     else {
314         my $inline_me = ($generate_as_inline_methods && $self->associated_class->instance_metaclass->is_inlinable);
315         my $method;
316         eval {
317             $method = $self->accessor_metaclass->new(
318                 attribute     => $self,
319                 is_inline     => $inline_me,
320                 accessor_type => $type,
321             );
322         };
323         confess "Could not create the '$type' method for " . $self->name . " because : $@" if $@;
324         $self->associate_method($method);
325         return ($accessor, $method);
326     }
327 }
328
329 sub install_accessors {
330     my $self   = shift;
331     my $inline = shift;
332     my $class  = $self->associated_class;
333
334     $class->add_method(
335         $self->process_accessors('accessor' => $self->accessor(), $inline)
336     ) if $self->has_accessor();
337
338     $class->add_method(
339         $self->process_accessors('reader' => $self->reader(), $inline)
340     ) if $self->has_reader();
341
342     $class->add_method(
343         $self->process_accessors('writer' => $self->writer(), $inline)
344     ) if $self->has_writer();
345
346     $class->add_method(
347         $self->process_accessors('predicate' => $self->predicate(), $inline)
348     ) if $self->has_predicate();
349
350     $class->add_method(
351         $self->process_accessors('clearer' => $self->clearer(), $inline)
352     ) if $self->has_clearer();
353
354     return;
355 }
356
357 {
358     my $_remove_accessor = sub {
359         my ($accessor, $class) = @_;
360         if (reftype($accessor) && reftype($accessor) eq 'HASH') {
361             ($accessor) = keys %{$accessor};
362         }
363         my $method = $class->get_method($accessor);
364         $class->remove_method($accessor)
365             if (blessed($method) && $method->isa('Class::MOP::Method::Accessor'));
366     };
367
368     sub remove_accessors {
369         my $self = shift;
370         # TODO:
371         # we really need to make sure to remove from the
372         # associates methods here as well. But this is
373         # such a slimly used method, I am not worried
374         # about it right now.
375         $_remove_accessor->($self->accessor(),  $self->associated_class()) if $self->has_accessor();
376         $_remove_accessor->($self->reader(),    $self->associated_class()) if $self->has_reader();
377         $_remove_accessor->($self->writer(),    $self->associated_class()) if $self->has_writer();
378         $_remove_accessor->($self->predicate(), $self->associated_class()) if $self->has_predicate();
379         $_remove_accessor->($self->clearer(),   $self->associated_class()) if $self->has_clearer();
380         return;
381     }
382
383 }
384
385 1;
386
387 __END__
388
389 =pod
390
391 =head1 NAME
392
393 Class::MOP::Attribute - Attribute Meta Object
394
395 =head1 SYNOPSIS
396
397   Class::MOP::Attribute->new('$foo' => (
398       accessor  => 'foo',        # dual purpose get/set accessor
399       predicate => 'has_foo'     # predicate check for defined-ness
400       init_arg  => '-foo',       # class->new will look for a -foo key
401       default   => 'BAR IS BAZ!' # if no -foo key is provided, use this
402   ));
403
404   Class::MOP::Attribute->new('$.bar' => (
405       reader    => 'bar',        # getter
406       writer    => 'set_bar',    # setter
407       predicate => 'has_bar'     # predicate check for defined-ness
408       init_arg  => ':bar',       # class->new will look for a :bar key
409       # no default value means it is undef
410   ));
411
412 =head1 DESCRIPTION
413
414 The Attribute Protocol is almost entirely an invention of this module,
415 and is completely optional to this MOP. This is because Perl 5 does not
416 have consistent notion of what is an attribute of a class. There are
417 so many ways in which this is done, and very few (if any) are
418 easily discoverable by this module.
419
420 So, all that said, this module attempts to inject some order into this
421 chaos, by introducing a consistent API which can be used to create
422 object attributes.
423
424 =head1 METHODS
425
426 =head2 Creation
427
428 =over 4
429
430 =item B<new ($name, ?%options)>
431
432 An attribute must (at the very least), have a C<$name>. All other
433 C<%options> are contained added as key-value pairs. Acceptable keys
434 are as follows:
435
436 =over 4
437
438 =item I<init_arg>
439
440 This should be a string value representing the expected key in
441 an initialization hash. For instance, if we have an I<init_arg>
442 value of C<-foo>, then the following code will Just Work.
443
444   MyClass->meta->construct_instance(-foo => "Hello There");
445
446 In an init_arg is not assigned, it will automatically use the
447 value of C<$name>.  If an explicit C<undef> is given for an init_arg,
448 an attribute value can't be specified during initialization.
449
450 =item I<builder>
451
452 The value of this key is the name of the method that will be
453 called to obtain the value used to initialize the attribute.
454 This should be a method in the class associated with the attribute,
455 not a method in the attribute class itself.
456
457 =item I<default>
458
459 The value of this key is the default value which
460 C<Class::MOP::Class::construct_instance> will initialize the
461 attribute to.
462
463 B<NOTE:>
464 If the value is a simple scalar (string or number), then it can
465 be just passed as is. However, if you wish to initialize it with
466 a HASH or ARRAY ref, then you need to wrap that inside a CODE
467 reference, like so:
468
469   Class::MOP::Attribute->new('@foo' => (
470       default => sub { [] },
471   ));
472
473   # or ...
474
475   Class::MOP::Attribute->new('%foo' => (
476       default => sub { {} },
477   ));
478
479 If you wish to initialize an attribute with a CODE reference
480 itself, then you need to wrap that in a subroutine as well, like
481 so:
482
483   Class::MOP::Attribute->new('&foo' => (
484       default => sub { sub { print "Hello World" } },
485   ));
486
487 And lastly, if the value of your attribute is dependent upon
488 some other aspect of the instance structure, then you can take
489 advantage of the fact that when the I<default> value is a CODE
490 reference, it is passed the (as yet unfinished) instance structure
491 as it's only argument. So you can do things like this:
492
493   Class::MOP::Attribute->new('$object_identity' => (
494       default => sub { Scalar::Util::refaddr($_[0]) },
495   ));
496
497 This last feature is fairly limited as there is no gurantee of
498 the order of attribute initializations, so you cannot perform
499 any kind of dependent initializations. However, if this is
500 something you need, you could subclass B<Class::MOP::Class> and
501 this class to acheive it. However, this is currently left as
502 an exercise to the reader :).
503
504 =item I<initializer>
505
506 This may be a method name (referring to a method on the class with this
507 attribute) or a CODE ref.  The initializer is used to set the attribute value
508 on an instance when the attribute is set during instance initialization.  When
509 called, it is passed the instance (as the invocant), the value to set, a
510 slot-setting CODE ref, and the attribute meta-instance.  The slot-setting code
511 is provided to make it easy to set the (possibly altered) value on the instance
512 without going through several more method calls.
513
514 This contrived example shows an initializer that sets the attribute to twice
515 the given value.
516
517   Class::MOP::Attribute->new('$doubled' => (
518       initializer => sub {
519           my ($instance, $value, $set) = @_;
520           $set->($value * 2);
521       },
522   ));
523
524 As method names can be given as initializers, one can easily make
525 attribute initialization use the writer:
526
527   Class::MOP::Attribute->new('$some_attr' => (
528       writer      => 'some_attr',
529       initializer => 'some_attr',
530   ));
531
532 Your writer will simply need to examine it's C<@_> and determine under
533 which context it is being called.
534
535 =back
536
537 The I<accessor>, I<reader>, I<writer>, I<predicate> and I<clearer> keys can
538 contain either; the name of the method and an appropriate default one will be
539 generated for you, B<or> a HASH ref containing exactly one key (which will be
540 used as the name of the method) and one value, which should contain a CODE
541 reference which will be installed as the method itself.
542
543 =over 4
544
545 =item I<accessor>
546
547 The I<accessor> is a standard perl-style read/write accessor. It will
548 return the value of the attribute, and if a value is passed as an argument,
549 it will assign that value to the attribute.
550
551 B<NOTE:>
552 This method will properly handle the following code, by assigning an
553 C<undef> value to the attribute.
554
555   $object->set_something(undef);
556
557 =item I<reader>
558
559 This is a basic read-only accessor, it will just return the value of
560 the attribute.
561
562 =item I<writer>
563
564 This is a basic write accessor, it accepts a single argument, and
565 assigns that value to the attribute. This method does not intentially
566 return a value, however perl will return the result of the last
567 expression in the subroutine, which returns in this returning the
568 same value that it was passed.
569
570 B<NOTE:>
571 This method will properly handle the following code, by assigning an
572 C<undef> value to the attribute.
573
574   $object->set_something();
575
576 =item I<predicate>
577
578 This is a basic test to see if any value has been set for the 
579 attribute. It will return true (C<1>) if the attribute has been set 
580 to any value (even C<undef>), and false (C<0>) otherwise.
581
582 B<NOTE:>
583 The predicate will return true even when you set an attribute's
584 value to C<undef>. This behaviour has changed as of version 0.43. In 
585 older versions, the predicate (erroneously) checked for attribute 
586 value definedness, instead of presence as it is now.
587
588 If you really want to get rid of the value, you have to define and 
589 use a I<clearer> (see below).
590
591 =item I<clearer>
592
593 This is the a method that will uninitialize the attr, reverting lazy values
594 back to their "unfulfilled" state.
595
596 =back
597
598 =item B<clone (%options)>
599
600 This will return a clone of the attribute instance, allowing the overriding
601 of various attributes through the C<%options> supplied.
602
603 =item B<initialize_instance_slot ($instance, $params)>
604
605 This method is used internally to initialize the approriate slot for this 
606 attribute in a given C<$instance>, the C<$params> passed are those that were
607 passed to the constructor.
608
609 =back
610
611 =head2 Value management
612
613 These methods are basically "backdoors" to the instance, which can be used
614 to bypass the regular accessors, but still stay within the context of the MOP.
615
616 These methods are not for general use, and should only be used if you really
617 know what you are doing.
618
619 =over 4
620
621 =item B<set_value ($instance, $value)>
622
623 Set the value without going through the accessor. Note that this may be done to
624 even attributes with just read only accessors.
625
626 =item B<set_initial_value ($instance, $value)>
627
628 This method sets the value without going through the accessor -- but it is only
629 called when the instance data is first initialized.
630
631 =item B<get_value ($instance)>
632
633 Return the value without going through the accessor. Note that this may be done
634 even to attributes with just write only accessors.
635
636 =item B<has_value ($instance)>
637
638 Return a boolean indicating if the item in the C<$instance> has a value in it.
639 This is basically what the default C<predicate> method calls.
640
641 =item B<clear_value ($instance)>
642
643 This will clear the value in the C<$instance>. This is basically what the default
644 C<clearer> would call. Note that this may be done even if the attirbute does not
645 have any associated read, write or clear methods.
646
647 =back
648
649 =head2 Informational
650
651 These are all basic read-only value accessors for the values
652 passed into C<new>. I think they are pretty much self-explanitory.
653
654 =over 4
655
656 =item B<name>
657
658 =item B<accessor>
659
660 =item B<reader>
661
662 =item B<writer>
663
664 =item B<predicate>
665
666 =item B<clearer>
667
668 =item B<initializer>
669
670 =item B<init_arg>
671
672 =item B<is_default_a_coderef>
673
674 =item B<default (?$instance)>
675
676 Return the default value for the attribute.
677
678 If you pass in an C<$instance> argument to this accessor and the
679 I<default> is a CODE reference, then the CODE reference will be
680 executed with the C<$instance> as its argument.
681
682 =item B<slots>
683
684 Return a list of slots required by the attribute. This is usually
685 just one, which is the name of the attribute.
686
687 =item B<get_read_method>
688
689 =item B<get_write_method>
690
691 Return the name of a method name suitable for reading / writing the value 
692 of the attribute in the associated class. Suitable for use whether 
693 C<reader> and C<writer> or C<accessor> was used.
694
695 =item B<get_read_method_ref>
696
697 =item B<get_write_method_ref>
698
699 Return the CODE reference of a method suitable for reading / writing the 
700 value of the attribute in the associated class. Suitable for use whether 
701 C<reader> and C<writer> or C<accessor> was specified or not.
702
703 NOTE: If no reader/writer/accessor was specified, this will use the 
704 attribute get_value/set_value methods, which can be very inefficient.
705
706 =back
707
708 =head2 Informational predicates
709
710 These are all basic predicate methods for the values passed into C<new>.
711
712 =over 4
713
714 =item B<has_accessor>
715
716 =item B<has_reader>
717
718 =item B<has_writer>
719
720 =item B<has_predicate>
721
722 =item B<has_clearer>
723
724 =item B<has_initializer>
725
726 =item B<has_init_arg>
727
728 =item B<has_default>
729
730 =item B<has_builder>
731
732 =back
733
734 =head2 Class association
735
736 These methods allow you to manage the attributes association with
737 the class that contains it. These methods should not be used
738 lightly, nor are they very magical, they are mostly used internally
739 and by metaclass instances.
740
741 =over 4
742
743 =item B<associated_class>
744
745 This returns the metaclass this attribute is associated with.
746
747 =item B<attach_to_class ($class)>
748
749 This will store a weaken reference to C<$class> internally. You should
750 note that just changing the class assocation will not remove the attribute
751 from it's old class, and initialize it (and it's accessors) in the new
752 C<$class>. It is up to you to do this manually.
753
754 =item B<detach_from_class>
755
756 This will remove the weakened reference to the class. It does B<not>
757 remove the attribute itself from the class (or remove it's accessors),
758 you must do that yourself if you want too. Actually if that is what
759 you want to do, you should probably be looking at
760 L<Class::MOP::Class::remove_attribute> instead.
761
762 =back
763
764 =head2 Attribute Accessor generation
765
766 =over 4
767
768 =item B<accessor_metaclass>
769
770 Accessors are generated by an accessor metaclass, which is usually
771 a subclass of C<Class::MOP::Method::Accessor>. This method returns
772 the name of the accessor metaclass that this attribute uses.
773
774 =item B<associate_method ($method)>
775
776 This will associate a C<$method> with the given attribute which is
777 used internally by the accessor generator.
778
779 =item B<associated_methods>
780
781 This will return the list of methods which have been associated with
782 the C<associate_method> methods. This is a good way of seeing what 
783 methods are used to manage a given attribute. 
784
785 =item B<install_accessors>
786
787 This allows the attribute to generate and install code for it's own
788 I<accessor/reader/writer/predicate> methods. This is called by
789 C<Class::MOP::Class::add_attribute>.
790
791 This method will call C<process_accessors> for each of the possible
792 method types (accessor, reader, writer & predicate).
793
794 =item B<process_accessors ($type, $value)>
795
796 This takes a C<$type> (accessor, reader, writer or predicate), and
797 a C<$value> (the value passed into the constructor for each of the
798 different types). It will then either generate the method itself
799 (using the C<generate_*_method> methods listed below) or it will
800 use the custom method passed through the constructor.
801
802 =item B<remove_accessors>
803
804 This allows the attribute to remove the method for it's own
805 I<accessor/reader/writer/predicate/clearer>. This is called by
806 C<Class::MOP::Class::remove_attribute>.
807
808 NOTE: This does not currently remove methods from the list returned
809 by C<associated_methods>, that is on the TODO list.
810
811 =back
812
813 =head2 Introspection
814
815 =over 4
816
817 =item B<meta>
818
819 This will return a B<Class::MOP::Class> instance which is related
820 to this class.
821
822 It should also be noted that B<Class::MOP> will actually bootstrap
823 this module by installing a number of attribute meta-objects into
824 it's metaclass. This will allow this class to reap all the benefits
825 of the MOP when subclassing it.
826
827 =back
828
829 =head1 AUTHORS
830
831 Stevan Little E<lt>stevan@iinteractive.comE<gt>
832
833 =head1 COPYRIGHT AND LICENSE
834
835 Copyright 2006-2008 by Infinity Interactive, Inc.
836
837 L<http://www.iinteractive.com>
838
839 This library is free software; you can redistribute it and/or modify
840 it under the same terms as Perl itself.
841
842 =cut
843
844