MooX::...::Util(3pm)

πŸ“¦
version 0.020 Β· 5 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu questing

πŸ’– MooX::...::Util β€” the whole vibe πŸ’–

okay so bestie, welcome to the MooX::...::Util(3pm) page 🌸 this is the little corner of the docs where the extra-goodies live, and honestly? it's giving "short but iconic." let's get into it 🫢


✨ NAME ✨

MooX::Struct::Util</purpose> β€” the extensions for MooX::Struct that would've been overkill to include in the main thing πŸŽ€ like, they're cute, they're useful, but cramming them into the core package would've been doing the most. so they live here instead πŸ’…


🌈 LAZY DEFAULTS 🌈

okay this is the main character of the whole page: sugar for lazily defaulted attributes πŸ“

and the way that the following two snippets are effectively the same?? literally identical behaviour, two different fits πŸ‘‘

fit number one β€” the long way, writing it all out by hand:

use MooX::Struct WebPage1 => [
   user_agent => [
      lazy     => 1,
      default  => sub { LWP::UserAgent->new },
   ],
];

fit number two β€” the glow-up, using lazy_default from this very module:

use MooX::Struct::Util qw(lazy_default);
use MooX::Struct WebPage2 => [
   user_agent => lazy_default { LWP::UserAgent->new },
];

see what happened there?? you imported lazy_default, and suddenly lazy => 1 plus default => sub { ... } collapses into one lil lazy_default { ... } block ✨ same result, way less typing, no cap. obsessed fr fr πŸ’–


πŸ› BUGS πŸ›

found something cursed?? πŸ’€ please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=MooX-Struct> β€” that's the queue, that's where the fix happens, go be a hero πŸ¦‹


πŸ‘€ SEE ALSO πŸ‘€

  • MooX::Struct β€” the main character that this whole page is vibing alongside πŸ’œ

πŸ‘‘ AUTHOR πŸ‘‘

Toby Inkster <tobyink@cpan.org> β€” the icon who wrote all of this πŸŽ€


this software is copyright (c) 2012-2013, 2017-2018 by Toby Inkster 🌟

and it's free software bestie β€” you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself πŸ’… so go wild (respectfully)


⚠️ 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.

like, no promises, no safety net, it is what it is 😭 read that one twice fr


and that's the whole page, bestie 🫢 this was MooX::...::Util(3pm), documented for perl v5.36.0 and dated 2022-12-12 β€” go forth and lazily default your attributes, you've got this πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from