1Mouse::Meta::Attribute(U3s)er Contributed Perl DocumentatMioounse::Meta::Attribute(3)
2
3
4

NAME

6       Mouse::Meta::Attribute - The Mouse attribute metaclass
7

VERSION

9       This document describes Mouse version v2.5.10
10

DESCRIPTION

12       This is a meta object protocol for Mouse attributes, which is a subset
13       of Moose::Meta::Attribute.
14

METHODS

16   "new(%options) -> Mouse::Meta::Attribute"
17       Instantiates a new Mouse::Meta::Attribute. Does nothing else.
18
19       It adds the following options to the constructor:
20
21       "is => 'ro', 'rw', 'bare'"
22           This provides a shorthand for specifying the "reader", "writer", or
23           "accessor" names. If the attribute is read-only ('ro') then it will
24           have a "reader" method with the same attribute as the name.
25
26           If it is read-write ('rw') then it will have an "accessor" method
27           with the same name. If you provide an explicit "writer" for a read-
28           write attribute, then you will have a "reader" with the same name
29           as the attribute, and a "writer" with the name you provided.
30
31           Use 'bare' when you are deliberately not installing any methods
32           (accessor, reader, etc.) associated with this attribute; otherwise,
33           Moose will issue a deprecation warning when this attribute is added
34           to a metaclass.
35
36       "isa => Type"
37           This option accepts a type. The type can be a string, which should
38           be a type name. If the type name is unknown, it is assumed to be a
39           class name.
40
41           This option can also accept a Moose::Meta::TypeConstraint object.
42
43           If you also provide a "does" option, then your "isa" option must be
44           a class name, and that class must do the role specified with
45           "does".
46
47       "does => Role"
48           This is short-hand for saying that the attribute's type must be an
49           object which does the named role.
50
51           This option is not yet supported.
52
53       "coerce => Bool"
54           This option is only valid for objects with a type constraint
55           ("isa"). If this is true, then coercions will be applied whenever
56           this attribute is set.
57
58           You can make both this and the "weak_ref" option true.
59
60       "trigger => CodeRef"
61           This option accepts a subroutine reference, which will be called
62           after the attribute is set.
63
64       "required => Bool"
65           An attribute which is required must be provided to the constructor.
66           An attribute which is required can also have a "default" or
67           "builder", which will satisfy its required-ness.
68
69           A required attribute must have a "default", "builder" or a
70           non-"undef" "init_arg"
71
72       "lazy => Bool"
73           A lazy attribute must have a "default" or "builder". When an
74           attribute is lazy, the default value will not be calculated until
75           the attribute is read.
76
77       "weak_ref => Bool"
78           If this is true, the attribute's value will be stored as a weak
79           reference.
80
81       "auto_deref => Bool"
82           If this is true, then the reader will dereference the value when it
83           is called. The attribute must have a type constraint which defines
84           the attribute as an array or hash reference.
85
86       "lazy_build => Bool"
87           Setting this to true makes the attribute lazy and provides a number
88           of default methods.
89
90             has 'size' => (
91                 is         => 'ro',
92                 lazy_build => 1,
93             );
94
95           is equivalent to this:
96
97             has 'size' => (
98                 is        => 'ro',
99                 lazy      => 1,
100                 builder   => '_build_size',
101                 clearer   => 'clear_size',
102                 predicate => 'has_size',
103             );
104
105   "associate_method(MethodName)"
106       Associates a method with the attribute. Typically, this is called
107       internally when an attribute generates its accessors.
108
109       Currently the argument MethodName is ignored in Mouse.
110
111   "verify_against_type_constraint(Item) -> TRUE | ERROR"
112       Checks that the given value passes this attribute's type constraint.
113       Returns "true" on success, otherwise "confess"es.
114
115   "clone_and_inherit_options(options) -> Mouse::Meta::Attribute"
116       Creates a new attribute in the owner class, inheriting options from
117       parent classes.  Accessors and helper methods are installed. Some error
118       checking is done.
119
120   "get_read_method_ref"
121   "get_write_method_ref"
122       Returns the subroutine reference of a method suitable for reading or
123       writing the attribute's value in the associated class. These methods
124       always return a subroutine reference, regardless of whether or not the
125       attribute is read- or write-only.
126

SEE ALSO

128       Moose::Meta::Attribute
129
130       Class::MOP::Attribute
131
132
133
134perl v5.32.1                      2021-01-27         Mouse::Meta::Attribute(3)
Impressum