1MooseX::Extended::CustoUms(e3r)Contributed Perl DocumentMaotoisoenX::Extended::Custom(3)
2
3
4
6 MooseX::Extended::Custom - Build a custom Moose, just for you.
7
9 version 0.35
10
12 Define your own version of MooseX::Extended:
13
14 package My::Moose {
15 use MooseX::Extended::Custom;
16
17 sub import {
18 my ( $class, %args ) = @_;
19 MooseX::Extended::Custom->create(
20 excludes => [qw/ StrictConstructor c3 /],
21 includes => ['multi'],
22 %args # you need this to allow customization of your customization
23 );
24 }
25 }
26
27 # no need for a true value
28
29 And then use it:
30
31 package Some::Class {
32 use My::Moose types => [qw/ArrayRef Num/];
33
34 param numbers ( isa => ArrayRef[Num] );
35
36 multi sub foo ($self) { ... }
37 multi sub foo ($self, $bar) { ... }
38 }
39
41 I hate boilerplate, so let's get rid of it. Let's say you don't want
42 namespace::autoclean or "carp", but you do want "multi". Plus, you have
43 custom versions of "carp" and "croak":
44
45 package Some::Class {
46 use MooseX::Extended
47 excludes => [qw/ autoclean carp /],
48 includes => ['multi'];
49 use My::Carp q(carp croak);
50
51 ... my code here
52 }
53
54 You probably get tired of typing that every time. Now you don't have
55 to.
56
57 package My::Moose {
58 use MooseX::Extended::Custom;
59 use My::Carp ();
60 use Import::Into;
61
62 sub import {
63 my ( $class, %args ) = @_;
64 my $target_class = caller;
65 MooseX::Extended::Custom->create(
66 excludes => [qw/ autoclean carp /],
67 includes => ['multi'],
68 %args # you need this to allow customization of your customization
69 );
70 My::Carp->import::into($target_class, qw(carp croak));
71 }
72 }
73
74 And then when you use "My::Moose", that's all set up for you.
75
76 If you need to change this on a "per class" basis:
77
78 use My::Moose
79 excludes => ['carp'],
80 types => [qw/ArrayRef Num/];
81
82 The above changes your "excludes" and adds "types", but doesn't change
83 your "includes".
84
86 Curtis "Ovid" Poe <curtis.poe@gmail.com>
87
89 This software is Copyright (c) 2022 by Curtis "Ovid" Poe.
90
91 This is free software, licensed under:
92
93 The Artistic License 2.0 (GPL Compatible)
94
95
96
97perl v5.38.0 2023-06-26 MooseX::Extended::Custom(3)