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 0.58
10

METHODS

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

SEE ALSO

124       Moose::Meta::Attribute
125
126       Class::MOP::Attribute
127
128
129
130perl v5.12.0                      2010-05-08         Mouse::Meta::Attribute(3)
Impressum