MooseX...elpers(3pm)

πŸ“¦
version 0.25 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

okay so, bestie, this is MooseX::AttributeHelpers β€” and the whole point of it is: (DEPRECATED) Extend your attribute interfaces. Yes it's the manual page for MooseX...elpers(3pm), yes the name is doing a little cutesy truncation thing on the terminal, no we are not going to make it a whole personality. Moving on. πŸ’…


✨ VERSION ✨

version 0.25 β€” that's the one, that's the vibe check, periodt.


πŸ¦‹ SYNOPSIS πŸ¦‹

okay so here's the moment, the main character entrance:

package MyClass;
use Moose;
use MooseX::AttributeHelpers;

has 'mapping' => (
    metaclass => 'Collection::Hash',
    is        => 'rw',
    isa       => 'HashRef[Str]',
    default   => sub { {} },
    provides  => {
        exists    => 'exists_in_mapping',
        keys      => 'ids_in_mapping',
        get       => 'get_mapping',
        set       => 'set_mapping',
    },
    curries  => {
        set       => { set_quantity => [ 'quantity' ] }
    }
);

# ...

my $obj = MyClass->new;
$obj->set_quantity(10);      # quantity => 10
$obj->set_mapping(4, 'foo'); # 4 => 'foo'
$obj->set_mapping(5, 'bar'); # 5 => 'bar'
$obj->set_mapping(6, 'baz'); # 6 => 'baz'

# prints 'bar'
print $obj->get_mapping(5) if $obj->exists_in_mapping(5);

# prints '4, 5, 6'
print join ', ', $obj->ids_in_mapping;

like. look at that. the generated methods are just there, living their best life. πŸ”₯


🌸 DESCRIPTION 🌸

BIG NEWS, and it's not the fun kind: this distribution is deprecated. everything it does has been moved into the Moose core as Moose::Meta::Attribute::Native. so like β€” no new code should be using this, fr fr. i'm not being dramatic, that's literally what the page says. 🫢

okay but for the history girlies: Moose attributes already give you a way to name your accessors, readers, writers, clearers and predicates. this library was the little extra something that handed you commonly used attribute helper methods for more specific types of data. ✨

and the way it works β€” as seen up in the SYNOPSIS β€” is you specify the extension through the metaclass parameter. the available meta classes are listed further down. iykyk. πŸ’–


πŸŽ€ PARAMETERS πŸŽ€

πŸ’œ provides

this points to a hashref that uses provider for the keys and method for the values. the method gets added to the object itself and does what you want. that's it, that's the whole deal.

πŸ’œ curries

this points to a hashref that uses provider for the keys, and for the value you've got two (2) choices:

  • you can supply {method => [ @args ]} for the values. the method will be added to the object itself β€” and it's always using @args as the beginning arguments. 🫢
  • another approach to curry a method provider is to supply a coderef instead of an arrayref. the code ref takes $self, $body, and any additional arguments passed to the final method.

so like, in code:

# ...

curries => {
    grep => {
        times_with_day => sub {
            my ($self, $body, $datetime) = @_;
            $body->($self, sub { $_->ymd eq $datetime->ymd });
        }
    }
}

# ...

$obj->times_with_day(DateTime->now); # takes datetime argument, checks day

see how it takes a datetime argument and checks the day? that's the bit. πŸ’…


🌈 METHOD PROVIDERS 🌈

okay so here's the whole roster, the full lineup, no skips, no cuts:

  • Number β€” common numerical operations.
  • String β€” common methods for string operations.
  • Counter β€” methods for incrementing and decrementing a counter attribute.
  • Bool β€” common methods for boolean values.
  • Collection::Hash β€” common methods for hash references.
  • Collection::ImmutableHash β€” common methods for inspecting hash references.
  • Collection::Array β€” common methods for array references.
  • Collection::List β€” common list methods for array references.

every single one of them, accounted for. πŸ’–


πŸ’€ DEPRECATION NOTICE πŸ’€

bestie. listen. the functionality in this family of modules is now implemented in the Moose core as Moose::Meta::Attribute::Native. no more development is being done on MooseX::AttributeHelpers, so the page literally encourages you to switch to native attribute traits. it's giving "we've moved on and so should you." 😭

🧚 SUPPORT 🧚

bugs may be submitted through the RT bug tracker at <https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-AttributeHelpers> β€” or, if you're feeling email-y, bug-MooseX-AttributeHelpers@rt.cpan.org (that's the mailto: bug-MooseX-AttributeHelpers@rt.cpan.org).

there is also a mailing list available for users of this distribution, at <http://lists.perl.org/list/moose.html>. 🌸

there is also an irc channel available for users of this distribution, at "#moose" on "irc.perl.org" β€” that's <irc://irc.perl.org/#moose>. come say hi, we don't bite. 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Stevan Little <stevan@iinteractive.com>


⭐ CONTRIBUTORS ⭐

the whole squad, in order, every single one:

  • Shawn M Moore <sartak@gmail.com>
  • Stevan Little <stevan.little@iinteractive.com>
  • Dave Rolsky <autarch@urth.org>
  • Florian Ragwitz <rafl@debian.org>
  • Yuval Kogman <nothingmuch@woobling.org>
  • Jason May <jason.a.may@gmail.com>
  • Karen Etheridge <ether@cpan.org>
  • Cory G Watson <gphat@onemogin.com>
  • Jesse Luehrs <doy@tozt.net>
  • Robert Boone <robo4288@gmail.com>
  • Bruno Vecchi <vecchi.b@gmail.com>
  • Johannes Plunien <plu@pqpq.de>
  • Mike Whitaker <mike@altrion.org>
  • Hans Dieter Pearcey <hdp@weftsoar.net>
  • Paul Driver <frodwith@gmail.com>
  • Robert 'phaylon' Sedlacek <rs@474.at>
  • Evan Carroll <me@evancarroll.com>
  • Dagfinn Ilmari Mannsaaker <ilmari@ilmari.org>
  • Chris Prather <cprather@hdpublishing.com>
  • Tom Lanyon <tom@netspot.com.au>
  • Chris Prather <chris@prather.org>
  • nperez <nperez@cpan.org>

(and yes, Chris Prather shows up twice. we love a repeat appearance. πŸ’…)


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


okay bestie that's the whole page, and one last little signature moment for you: this was perl v5.34.0, dated 2022-06-15, and the page name folded at the top was MooseX...elpers(3pm). go forth, use Moose::Meta::Attribute::Native, and don't use the deprecated one. mwah. πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from