Mason:...ributes(3pm)

πŸ“¦
version 2.24 Β· 2 versions
  • 2.24 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 2.24 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’… Mason::Plugin::LvalueAttributes β€” like, the whole vibe

okay bestie, so this is a page from the User Contributed Perl Documentation for Mason::Plugin::LvalueAttributes (yes that's the manual name, it's giving 3pm section energy, we move). And what does it do?? It creates lvalue accessors for every rw component attribute. Slay.


✨ SYNOPSIS ✨

<%class>
has 'a' => (is => "rw")
has 'b' => (is => "ro")
</%class>

<%init>
# set a to 5
$.a = 5;

# set a to 6
$.a(6);

# error
$.b = 7;
</%init>

like. look at that. $.a = 5?? iconic behavior, no notes. πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

So this plugin creates an Lvalue accessor for every single read/write attribute in the component. Which means instead of writing this kinda clunky thing:

$.name( "Foo" );

you get to use the way more natural syntax:

$.name = "Foo";

it's giving effortless. it's giving main character. πŸ’–


😭 WARNING 😭 (read this one fr fr)

Standard Moose setter features like type checking, triggers, and coercion? Yeah, those will not work on Lvalue attributes. nope. gone. not invited to the party. πŸ’€

So you should only use this plugin when the convenience of the Lvalue attributes outweighs the need for setter features. Like, if you need your setters to do their little tricks, this plugin is not the one, bestie. vibe check accordingly. 🫢


🌸 ACKNOWLEDGEMENTS 🌸

Inspired by Christopher Brown's MooseX::Meta::Attribute::Lvalue. credit where credit is due, we love a muse. ✨


πŸ‘‘ SEE ALSO πŸ‘‘

  • Mason

(go read it, iykyk πŸ’œ)


🧚 AUTHOR 🧚

Jonathan Swartz <swartz@pobox.com> β€” legend behavior honestly.


This software is copyright (c) 2012 by Jonathan Swartz.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


and that's the whole page, bestie!! πŸ“ this one was documented for perl v5.34.0 and dated 2022-05-27, which is lowkey ancient but she still eats. mwah πŸ’…βœ¨

πŸ“¦ where this page comes from