MooseX...nitArg(3pm)

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

πŸ’– NAME πŸ’–

MooseX::MultiInitArg β€” it's giving attributes with aliases for constructor arguments. bestie, one attribute, many names. iconic behavior honestly.


✨ SYNOPSIS ✨

package Thinger;
use Moose;
      use MooseX::MultiInitArg;

has 'data' => (
    metaclass => 'MultiInitArg',

    # For composability, you could use the following:
    # traits => ['MooseX::MultiInitArg::Trait'],

    is        => 'ro',
    isa       => 'Str',
    init_args => [qw(munge frobnicate)],
);

package main;

# All these are equivalent
my $foo = Thinger->new(data => 'foo');
my $foo = Thinger->new(munge => 'foo');
my $foo = Thinger->new(frobnicate => 'foo');

all three of those? same thing. literally the same object. no cap. πŸ¦‹


🌸 DESCRIPTION 🌸

okay so picture this: you've ever wanted to be able to call an attribute any number of things while you're passing arguments to your object constructor? Now You Can. πŸ’… periodt.

the primary motivator β€” and this is the real tea πŸ“ β€” is that the author had some attributes that were named inconsistently, and wanted to rename them without breaking backwards compatibility with the existing API. the way that's such a mood. main character energy from a metaclass fr fr.


πŸŽ€ AUTHOR πŸŽ€

Paul Driver, "<frodwith at cpan.org>" 🫢


Copyright 2007-2013 by Paul Driver.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. πŸ’œ


and that's the whole page bestie, you ate it up πŸŒˆπŸ’–

this little beauty came to you via perl v5.34.0, dated 2022-06-15, filed under MooseX...nitArg(3pm) β€” go forth and alias your init args, queen πŸ‘‘βœ¨

πŸ“¦ where this page comes from