MooseX...uteTags(3pm)

πŸ’– MooseX::AttributeTags πŸ’–

okay so bestie, welcome to the User Contributed Perl Documentation for section 3pm β€” this is MooseX::AttributeTags, and it's literally just "tag your Moose attributes." that's the whole name. that's the whole vibe. πŸŽ€


✨ NAME ✨

MooseX::AttributeTags β€” tag your Moose attributes. slay. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

okay watch this, it's giving main character energy:

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 how hidden is just... there? like it always belonged? that's the whole point bestie. 😌✨


🌸 DESCRIPTION 🌸

so MooseX::AttributeTags is a factory for attribute traits. that's it, that's the job. and the way that literally all the work happens inside the import method?? obsessed. no cap. 🫢


πŸ’œ Methods πŸ’œ

import(@optlist)

okay so the option list is just a list of trait names to create β€” and those get exported to the caller package as constants. cute, right? ⭐

each trait name can optionally be followed by an arrayref of attributes to be created inside that trait. (in the SYNOPSIS up there, the SerializationStyle trait gets an attribute called hidden β€” she's shy, she's iconic. πŸ™ˆ)

and then, each of those attributes can optionally be followed by one of these three besties:

  • A coderef which provides a default value for the attribute. πŸ“
  • A type constraint object (like the ones from Types::Standard or MooseX::Types β€” not a type constraint string, ok?? like actually not) to validate the attribute.
  • An arrayref or hashref providing options similar to those you'd hand to Moose's has keyword.

and btw? in that SYNOPSIS example, a constant called User::SerializationStyle gets defined. yes really. πŸ’«

my $attr = User->meta->get_attribute('username');
$attr->does(User::SerializationStyle);    # true
$attr->hidden;                            # false

look at her go. does says true, hidden says false. fr fr. πŸ”₯


πŸ’€ BUGS πŸ’€

not me having to tell you this 😭 β€” please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=MooseX-AttributeTags>.

no like actually report them bestie, don't just vibe about it in the group chat. 🫢

🌈 SEE ALSO 🌈

  • Moose.

that's it. one (1) whole friend. quality over quantity. πŸ‘‘


πŸŽ€ AUTHOR πŸŽ€

Toby Inkster <tobyink@cpan.org>. iconic behavior, honestly. πŸ’–


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. ✨


🧚 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.

read that again. no warranty bestie. none. zero. zip. nada. πŸ’€


and that's the whole page!! πŸ¦‹ this was generated from perl v5.32.1, dated 2021-09-12, and yeah the doc title is literally MooseX...uteTags(3pm) β€” she got cut off mid-name and honestly?? relatable. πŸ’… bye bestie, go tag some attributes!! 🌈✨

πŸ“¦ where this page comes from