MooseX...hained(3pm)

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

πŸ’– NAME πŸ’–

MooseX::Attribute::Chained β€” bestie, it's an attribute that hands the instance right back to you so you can chain your little heart out ✨


🌸 VERSION 🌸

version 1.0.3 β€” she's giving established, she's giving stable πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

okay so picture this, you're writing a package Test, you use Moose, and you set up an attribute with the Chained trait:

package Test;
use Moose;

has debug => (
    traits => [ 'Chained' ],
    is => 'rw',
    isa => 'Bool',
);

sub complex_method
{
    my $self = shift;

    #...

    print "helper message" if $self->debug;

    #...
}

1;

and the way this slays is it lets you do:

my $test = Test->new;
$test->debug(1)->complex_method;

$test->debug(1); # returns $test
$test->debug;    # returns 1

not me getting emotional over a setter that returns $self 😭 like, look at her. write operation returns the object, read operation returns the actual value. iconic behaviour, no cap.


πŸ¦‹ DESCRIPTION πŸ¦‹

MooseX::Attribute::Chained is a Moose Trait, and what it does is let you do method chaining on accessors by returning $self on write/set operations. that's the whole vibe. that's the entire thing. you set a thing, you get the object back, you immediately call another thing on it. one line, many methods, chef's kiss πŸ‘‘


πŸ‘‘ AUTHORS πŸ‘‘

the legends responsible, fr fr:

  • Tom Hukins <tom@eborcom.com>
  • Moritz Onken <onken@netcubed.de>
  • David McLaughlin <david@dmclaughlin.com>

this software is copyright (c) 2017 by Tom Hukins. 🫢

it's free software β€” you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. so, y'know. same deal as Perl. go wild, respectfully. 🌈


πŸ“ BUGS πŸ“

found a bug? got a feature request? don't suffer in silence, bestie β€” report it on the bugtracker website at:

http://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Attribute-Chained

or email it to bug-moosex-attribute-chained at rt.cpan.org πŸ’Œ

okay and when you submit a bug or a request, please please please include a test-file or a patch to an existing test-file that shows off the bug or the feature you want. it makes everything so much easier and the maintainers will love you for it πŸ’–

anyway that's the whole page!! πŸŽ€ this was MooseX::Attribute::Chained from the User Contributed Perl Documentation, perl v5.34.0, dated 2022-06-15. go forth and chain your accessors, you absolute main character πŸŒŸπŸ’…

πŸ“¦ where this page comes from