MooseX::AttributeTags(3pm) | User Contributed Perl Documentation | MooseX::AttributeTags(3pm) |
MooseX::AttributeTags - tag your Moose attributes
package User; use Moose; use MooseX::Types::Moose 'Bool'; use MooseX::AttributeTags ( SerializationStyle => [ hidden => Bool, ], ); has username => ( traits => [ SerializationStyle ], is => 'ro', hidden => 0, ); has password => ( traits => [ SerializationStyle ], is => 'rw', hidden => 1, );
MooseX::AttributeTags is a factory for attribute traits. All the work is done in the import method.
Each trait name may be optionally followed by an arrayref of attributes to be created within the trait. (In the SYNOPSIS, the "SerializationStyle" trait gets an attribute called "hidden".)
Each attribute may be optionally followed by one of:
Note that in the SYNOPSIS example, a constant "User::SerializationStyle" is defined.
my $attr = User->meta->get_attribute('username'); $attr->does(User::SerializationStyle); # true $attr->hidden; # false
Please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=MooseX-AttributeTags>.
Moose.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2013, 2017, 2019 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2021-09-12 | perl v5.32.1 |