The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Class::MOP::Method::Accessor - Method Meta Object for accessors

SYNOPSIS

    use Class::MOP::Method::Accessor;

    my $reader = Class::MOP::Method::Accessor->new(
        attribute     => $attribute,
        is_inline     => 1,
        accessor_type => 'reader',
    );

    $reader->body->($instance); # call the reader method

DESCRIPTION

This is a Class::MOP::Method subclass which is used interally by Class::MOP::Attribute to generate accessor code. It can handle generation of readers, writers, predicate and clearer methods, both as closures and as more optimized inline methods.

METHODS

new (%options)

This creates the method based on the criteria in %options, these options are:

attribute

This must be an instance of Class::MOP::Attribute which this accessor is being generated for. This paramter is required.

accessor_type

This is a string from the following set; reader, writer, accessor, predicate or clearer. This is used to determine which type of method is to be generated.

is_inline

This is a boolean to indicate if the method should be generated as a closure, or as a more optimized inline version.

accessor_type

This returns the accessor type which was passed into new.

is_inline

This returns the boolean which was passed into new.

associated_attribute

This returns the attribute instance which was passed into new.

initialize_body

This will actually generate the method based on the specified criteria passed to the constructor.

Method Generators

These methods will generate appropriate code references for the various types of accessors which are supported by Class::MOP::Attribute. The names pretty much explain it all.

generate_accessor_method
generate_accessor_method_inline
generate_clearer_method
generate_clearer_method_inline
generate_predicate_method
generate_predicate_method_inline
generate_reader_method
generate_reader_method_inline
generate_writer_method
generate_writer_method_inline

AUTHORS

Stevan Little <stevan@iinteractive.com>

COPYRIGHT AND LICENSE

Copyright 2006-2008 by Infinity Interactive, Inc.

http://www.iinteractive.com

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.