MooseX:...:Custom(3)

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

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

okay bestie, so this page is all about MooseX::Extended::Role::Custom β€” a lil manual for building your very own custom Moose::Role. just for you. nobody else. main character energy fr.


✨ NAME ✨

MooseX::Extended::Role::Custom β€” build a custom Moose::Role, just for you. πŸŽ€

🌸 VERSION 🌸

version 0.35

πŸ¦‹ SYNOPSIS πŸ¦‹

okay so step one: define your own version of MooseX::Extended. literally just:

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

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

# no need for a true value
no cap, you genuinely do not need a true value at the end there. she's already slaying. πŸ’…

and then you use it, like:

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

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

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

ate. periodt. 🌈

πŸ‘‘ DESCRIPTION πŸ‘‘

okay so, real talk: I hate boilerplate, so let's get rid of it. be gone. not me writing the same setup over and over 😭

so let's say you don't want warnings on classes implicitly overriding role methods, you don't want namespace::autoclean, and you don't want carp β€” but you do want multi. plus, you've got your own custom versions of carp and croak. here's what that looks like:

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

    ... my code here
}

and like… you probably get tired of typing that every single time, right? honestly valid. but now you don't have to. 🫢

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, literally everything is set up for you already. iconic behavior honestly ✨

and if you need to change this on a per class basis:

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

so the way that works: the above changes your excludes and adds types, but it does not change your includes. iykyk. πŸ’œ

🌟 AUTHOR 🌟

Curtis "Ovid" Poe <curtis.poe@gmail.com> β€” king behavior πŸ‘‘

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

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

and that's the whole vibe check, bestie πŸŽ€ this was perl v5.42.0, dated 2025-07-25, and the manual name is MooseX:...:Custom(3) β€” thanks for reading, mwah πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from