MooseX...ounter(3pm)
π NAME π
MooseX::AttributeHelpers::Trait::Counter β it's giving simple counter attribute, bestie π
β¨ VERSION β¨
version 0.25 π«Ά
π SYNOPSIS π
okay so here's the whole vibe, copy-paste ready:
package MyHomePage;
use Moose;
use MooseX::AttributeHelpers;
has 'counter' => (
metaclass => 'Counter',
is => 'ro',
isa => 'Num',
default => sub { 0 },
provides => {
inc => 'inc_counter',
dec => 'dec_counter',
reset => 'reset_counter',
}
);
my $page = MyHomePage->new();
$page->inc_counter; # same as $page->counter($page->counter + 1);
$page->dec_counter; # same as $page->counter($page->counter - 1);
π¦ DESCRIPTION π¦
so this module hands you a simple counter attribute β like, a little number that lives in your object and can be incremented and decremented. that's the whole thing. iconic, honestly. β¨
and here's the cute part: if your attribute definition doesn't include any of is, isa, default or provides, but does use the "Counter" metaclass, then this module just applies the defaults from the SYNOPSIS up there for you. no cap. which means you can do an absolutely bare-bones counter like this:
has 'foo' => (metaclass => 'Counter');
$obj->inc_foo;
and it just works. main character energy fr fr π
π METHODS π
metaβ yeah, the meta thing πΈmethod_providerβ the method provider situation πhas_method_providerβ checks whether there's a method provider πhelper_typeβ the helper type π¦process_options_for_providesβ this one runs before its superclass method, okay? important. π«Άcheck_provides_valuesβ and this one runs after its superclass method. so, before and after. periodt. π
π PROVIDED METHODS π
okay so before we get into these β super important, do not skip this: all of these methods do in place modification of the value stored in the attribute. like, they're not handing you back a fresh copy, they are reaching in and changing the actual thing. π
setβ sets the counter to the value you give it. π―incβ bumps the value stored in this slot up by1. and if you hand it an argument, the counter gets increased by the amount you specified. π₯decβ drops the value stored in this slot down by1. and if you hand it an argument, the counter gets increased by the amount you specified. (yep, that's what it says π)resetβ resets the value stored in this slot back to its default value. it's giving factory reset but make it cute. π
π SUPPORT π
if something's busted, here's where to go:
- bugs can be submitted through the RT bug tracker <https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-AttributeHelpers> (or you can email
bug-MooseX-AttributeHelpers@rt.cpan.org<mailto:bug-MooseX-AttributeHelpers@rt.cpan.org>). π - there's also a mailing list for users of this distribution, over at <http://lists.perl.org/list/moose.html>. π
- and there's an irc channel too, for users of this distribution β
"#moose"on"irc.perl.org"<irc://irc.perl.org/#moose>. come say hi π¬
π AUTHOR π
Stevan Little <stevan@iinteractive.com> β thank you king π«‘
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2007 by Stevan Little and Infinity Interactive, Inc. π
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. β¨
okay bestie that's the whole page!! π₯³ it's from perl v5.34.0, dated 2022-06-15, and this whole manual page is MooseX...ounter(3pm) from the User Contributed Perl Documentation. go forth and counter, you've got this ππ¦πΈπ
π¦ where this page comes from
- debian bookworm: libmoosex-attributehelpers-perl 0.25-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmoosex-attributehelpers-perl 0.25-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmoosex-attributehelpers-perl 0.25-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmoosex-attributehelpers-perl 0.25-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmoosex-attributehelpers-perl 0.25-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms