logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

MooseX::AttributeTags - tag your Moose attributes

Author

       Toby Inkster <tobyink@cpan.org>.

Bugs

       Please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=MooseX-AttributeTags>.

Description

       MooseX::AttributeTags is a factory for attribute traits. All the work is done in the import method.

   Methods
       "import(@optlist)"
           The  option  list is a list of trait names to create (which will be exported to the caller package as
           constants).

           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:

           •   A coderef which provides a default value for the attribute.

           •   A  type constraint object (such as those provided by Types::Standard or MooseX::Types; not a type
               constraint string) to validate the attribute.

           •   An arrayref or hashref providing options similar to those given to Moose's "has" keyword.

       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

Disclaimer Of Warranties

       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.

perl v5.32.1                                       2021-09-12                         MooseX::AttributeTags(3pm)

Name

       MooseX::AttributeTags - tag your Moose attributes

See Also

       Moose.

Synopsis

          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,
          );

See Also