MooseX:...:Custom(3)

πŸ“¦
version 0.35 Β· 2 versions
, in fedora 43

πŸ’– MooseX::Extended::Custom πŸ’–

okay bestie, so this is MooseX:...:Custom(3) from the User Contributed Perl Documentation set β€” the manual page for MooseX::Extended::Custom. it's giving build-your-own-Moose, and honestly? iconic. πŸŽ€


✨ NAME ✨

MooseX::Extended::Custom β€” Build a custom Moose, just for you. πŸ’…

like, your Moose. bespoke. one of one. no cap.


🌸 VERSION 🌸

version 0.35 β€” that's the one we're vibing with rn. πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

okay so step one: you define your own version of MooseX::Extended, and it looks like this:

package My::Moose {
    use MooseX::Extended::Custom;

    sub import {
        my ( $class, %args ) = @_;
        MooseX::Extended::Custom->create(
            excludes => [qw/ StrictConstructor c3 /],
            includes => ['multi'],
            %args    # you need this to allow customization of your customization
        );
    }
}

# no need for a true value

bestie the # no need for a true value comment?? that's the whole personality. no 1; required. slay. ✨

And then β€” step two β€” you actually use it:

package Some::Class {
    use My::Moose types => [qw/ArrayRef Num/];

    param numbers ( isa => ArrayRef[Num] );

    multi sub foo ($self)       { ... }
    multi sub foo ($self, $bar) { ... }
}

look at those multi subs. look at them. 🫢


πŸ’œ DESCRIPTION πŸ’œ

I hate boilerplate, so let's get rid of it. πŸ—‘οΈβœ¨ fr fr, boilerplate is the enemy and this module is the main character who defeats it.

so let's say β€” hypothetically, for the plot β€” that you don't want namespace::autoclean or "carp", but you do want "multi". and also you've got your own custom versions of "carp" and "croak". then it'd look like this:

package Some::Class {
    use MooseX::Extended
      excludes => [qw/ autoclean carp /],
      includes => ['multi'];
    use My::Carp q(carp croak);

    ... my code here
}

ngl you're probably getting SO tired of typing that every single time. 😭 and like… now you don't have to?? because:

package My::Moose {
    use MooseX::Extended::Custom;
    use My::Carp ();
    use Import::Into;

    sub import {
        my ( $class, %args ) = @_;
        my $target_class = caller;
        MooseX::Extended::Custom->create(
            excludes => [qw/ autoclean carp /],
            includes => ['multi'],
            %args    # you need this to allow customization of your customization
        );
        My::Carp->import::into($target_class, qw(carp croak));
    }
}

and then when you use "My::Moose", all of that is already set up for you. no extra typing. no copy-paste crimes. just vibes. 🌈


πŸ¦‹ per-class customization πŸ¦‹

but wait, there's more β€” if you need to change this on a "per class" basis:

use My::Moose
  excludes => ['carp'],
  types    => [qw/ArrayRef Num/];

The above changes your "excludes" and adds "types", but doesn't change your "includes". periodt. πŸ’…


πŸ‘‘ AUTHOR πŸ‘‘

Curtis "Ovid" Poe <curtis.poe@gmail.com> πŸ’–


This software is Copyright (c) 2022 by Curtis "Ovid" Poe.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

okay and that's the whole page bestie!! πŸŽ€ this was perl v5.42.0, dated 2025-07-25, and it's the MooseX:...:Custom(3) page from User Contributed Perl Documentation. go forth and build your custom Moose. it's giving main character energy. πŸ’…βœ¨πŸ«Ά

πŸ“¦ where this page comes from