Class::MOP::Method::Accessor - Method Meta Object for accessors
| Use Case | Command | Description |
|---|---|---|
| ๐ Create a reader accessor | Class::MOP::Method::Accessor->new(attribute => $attr, accessor_type => 'reader') |
Generate a read-only accessor for an attribute |
| โ๏ธ Create a writer accessor | ... accessor_type => 'writer' |
Generate a write-only accessor |
| ๐ Create a read/write accessor | ... accessor_type => 'accessor' |
Generate a combined reader/writer |
| โ Create a predicate | ... accessor_type => 'predicate' |
Generate a boolean check for attribute existence |
| ๐งน Create a clearer | ... accessor_type => 'clearer' |
Generate a method to clear attribute value |
| ๐ท๏ธ Check accessor type | $metamethod->accessor_type |
Get the type of accessor ('reader', 'writer', etc.) |
| ๐ง Check if inlined | $metamethod->is_inline |
Returns boolean if method is inlined |
| ๐ฆ Get associated attribute | $metamethod->associated_attribute |
Retrieve the Class::MOP::Attribute object |
| โก Execute the generated method | $metamethod->body->execute($instance) |
Call the accessor method on an instance |
version 2.2200
use Class::MOP::Method::Accessor;
my $reader = Class::MOP::Method::Accessor->new(
attribute => $attribute,
is_inline => 1,
accessor_type => 'reader',
);
$reader->body->execute($instance); # call the reader method
This is a subclass of Class::MOP::Method which is used by Class::MOP::Attribute to generate accessor code. It handles generation of readers, writers, predicates and clearers. For each type of method, it can either create a subroutine reference, or actually inline code by generating a string and eval'ing it.
Class::MOP::Method::Accessor->new(%options) โ This returns a new Class::MOP::Method::Accessor based on the %options provided.
attribute โ This is the Class::MOP::Attribute for which accessors are being generated. This option is required.accessor_type โ This is a string which should be one of reader, writer, accessor, predicate, or clearer. This is the type of method being generated. This option is required.is_inline โ This indicates whether or not the accessor should be inlined. This defaults to false.name โ The method name (without a package name). This is required.package_name โ The package name for the method. This is required.$metamethod->accessor_type โ Returns the accessor type which was passed to new.$metamethod->is_inline โ Returns a boolean indicating whether or not the accessor is inlined.$metamethod->associated_attribute โ This returns the Class::MOP::Attribute object which was passed to new.$metamethod->body โ The method itself is generated when the accessor object is constructed.This software is copyright (c) 2006 by Infinity Interactive, Inc.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
perl v5.34.0 2022-02-06 Class::MOP::Method::Accessor(3pm)
Generated by phpman v4.9.26-5-g7740029 Author: Che Dong Under GNU General Public License
2026-08-26 05:55 @216.73.217.127
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)