28 Mar 2020 13:17:36 UTC
- Distribution: Mouse
- Source (raw)
- Browse (raw)
- How to Contribute
- Repository (git clone)
- Issues (12)
- KwaliteeBus factor: 8
- License: perl_5
- Perl: v5.8.5
- Activity24 month
- Download (215.18KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:30 non-PAUSE usersSKAJI Shoichi Kajiand 45 contributors
- Shawn M Moore <sartak at gmail.com>
- Aleksandr Matveev
- Alex Solovey
- Bernhard M. Wiedemann
- Boutros Lab User
- Chris Prather
- Daisuke Maki (lestrrat)
- Daisuke Maki
- David Steinbrunner
- Eiichi Tsukata
- FUJI Goro (gfx)
- Fuji, Goro
- Ingy dot Net
- Jesse Vincent
- Joel Bernstein
- John SJ Anderson
- Kensaku Araga
- Kent Fredric
- Luca Ferrari
- Masahiro Honma
- Matt S Trout
- Michael G. Schwern
- NAKAGAWA Masaki
- Nick Woolley
- Piotr Roszatycki
- Reini Urban
- Ricardo SIGNES
- Sergey Kolychev
- Sergiy Zuban
- Shawn M Moore
- Stanislaw Pusep
- Syohei YOSHIDA
- Todd Rinaldo
- Tokuhiro Matsuno
- Tomas Doran (t0m)
- Vincent Pit
- Yuval Kogman
- Ævar Arnfjörð Bjarmason
- 大沢 和宏
- SEE ALSO
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:
is => 'ro', 'rw', 'bare'
This provides a shorthand for specifying the
accessornames. If the attribute is read-only ('ro') then it will have a
readermethod with the same attribute as the name.
If it is read-write ('rw') then it will have an
accessormethod with the same name. If you provide an explicit
writerfor a read-write attribute, then you will have a
readerwith the same name as the attribute, and a
writerwith 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.
isa => Type
This option accepts a type. The type can be a string, which should be a type name. If the type name is unknown, it is assumed to be a class name.
This option can also accept a Moose::Meta::TypeConstraint object.
If you also provide a
doesoption, then your
isaoption must be a class name, and that class must do the role specified with
does => Role
This is short-hand for saying that the attribute's type must be an object which does the named role.
This option is not yet supported.
coerce => Bool
This option is only valid for objects with a type constraint (
isa). If this is true, then coercions will be applied whenever this attribute is set.
You can make both this and the
trigger => CodeRef
This option accepts a subroutine reference, which will be called after the attribute is set.
required => Bool
An attribute which is required must be provided to the constructor. An attribute which is required can also have a
builder, which will satisfy its required-ness.
A required attribute must have a
builderor a non-
lazy => Bool
A lazy attribute must have a
builder. When an attribute is lazy, the default value will not be calculated until the attribute is read.
weak_ref => Bool
If this is true, the attribute's value will be stored as a weak reference.
auto_deref => Bool
If this is true, then the reader will dereference the value when it is called. The attribute must have a type constraint which defines the attribute as an array or hash reference.
lazy_build => Bool
Setting this to true makes the attribute lazy and provides a number of default methods.
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
trueon success, otherwise
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.