Mouse::Meta::Attribute(3pm) | User Contributed Perl Documentation | Mouse::Meta::Attribute(3pm) |
Mouse::Meta::Attribute - The Mouse attribute metaclass
This document describes Mouse version v2.5.10
This is a meta object protocol for Mouse attributes, which is a subset of Moose::Meta::Attribute.
Instantiates a new Mouse::Meta::Attribute. Does nothing else.
It adds the following options to the constructor:
If it is read-write ('rw') then it will have an "accessor" method with the same name. If you provide an explicit "writer" for a read-write attribute, then you will have a "reader" with the same name as the attribute, and a "writer" with the name you provided.
Use 'bare' when you are deliberately not installing any methods (accessor, reader, etc.) associated with this attribute; otherwise, Moose will issue a deprecation warning when this attribute is added to a metaclass.
This option can also accept a Moose::Meta::TypeConstraint object.
If you also provide a "does" option, then your "isa" option must be a class name, and that class must do the role specified with "does".
This option is not yet supported.
You can make both this and the "weak_ref" option true.
A required attribute must have a "default", "builder" or a non-"undef" "init_arg"
has 'size' => ( is => 'ro', lazy_build => 1, );
is equivalent to this:
has 'size' => ( is => 'ro', lazy => 1, builder => '_build_size', clearer => 'clear_size', predicate => 'has_size', );
Associates a method with the attribute. Typically, this is called internally when an attribute generates its accessors.
Currently the argument MethodName is ignored in Mouse.
Checks that the given value passes this attribute's type constraint. Returns "true" on success, otherwise "confess"es.
Creates a new attribute in the owner class, inheriting options from parent classes. Accessors and helper methods are installed. Some error checking is done.
Returns the subroutine reference of a method suitable for reading or writing the attribute's value in the associated class. These methods always return a subroutine reference, regardless of whether or not the attribute is read- or write-only.
Moose::Meta::Attribute
Class::MOP::Attribute
2022-10-20 | perl v5.36.0 |