line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
# ABSTRACT: Build a custom Moose, just for you. |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use 5.20.0; |
5
|
1
|
|
|
1
|
|
167424
|
use strict; |
|
1
|
|
|
|
|
13
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
18
|
|
7
|
1
|
|
|
1
|
|
3
|
use true; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
8
|
1
|
|
|
1
|
|
367
|
use MooseX::Extended::Core qw( |
|
1
|
|
|
|
|
2705
|
|
|
1
|
|
|
|
|
5
|
|
9
|
1
|
|
|
|
|
110
|
_enabled_features |
10
|
|
|
|
|
|
|
_disabled_warnings |
11
|
|
|
|
|
|
|
); |
12
|
1
|
|
|
1
|
|
1392
|
use MooseX::Extended (); |
|
1
|
|
|
|
|
4
|
|
13
|
1
|
|
|
1
|
|
747
|
use namespace::autoclean; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
30
|
|
14
|
1
|
|
|
1
|
|
7
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.34'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my @caller = caller(0); |
18
|
|
|
|
|
|
|
my $custom_moose = $caller[0]; # this is our custom Moose definition |
19
|
1
|
|
|
1
|
|
17
|
true->import::into($custom_moose) unless $caller[1] =~ /^\(eval/; |
20
|
1
|
|
|
|
|
23
|
strict->import::into($custom_moose); |
21
|
1
|
50
|
|
|
|
34
|
warnings->import::into($custom_moose); |
22
|
1
|
|
|
|
|
1293
|
namespace::autoclean->import::into($custom_moose); |
23
|
1
|
|
|
|
|
201
|
feature->import( _enabled_features() ); |
24
|
1
|
|
|
|
|
158
|
warnings->unimport(_disabled_warnings); |
25
|
1
|
|
|
|
|
240
|
} |
26
|
1
|
|
|
|
|
5
|
|
27
|
|
|
|
|
|
|
my ( $class, %args ) = @_; |
28
|
|
|
|
|
|
|
my $target_class = caller(1); # this is the class consuming our custom Moose |
29
|
|
|
|
|
|
|
MooseX::Extended->import( |
30
|
2
|
|
|
2
|
0
|
4144
|
%args, |
31
|
2
|
|
|
|
|
22
|
call_level => 1, |
32
|
2
|
|
|
|
|
77
|
for_class => $target_class, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=pod |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=encoding UTF-8 |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 NAME |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
MooseX::Extended::Custom - Build a custom Moose, just for you. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 VERSION |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
version 0.34 |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SYNOPSIS |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Define your own version of L<MooseX::Extended>: |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
package My::Moose { |
56
|
|
|
|
|
|
|
use MooseX::Extended::Custom; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub import { |
59
|
|
|
|
|
|
|
my ( $class, %args ) = @_; |
60
|
|
|
|
|
|
|
MooseX::Extended::Custom->create( |
61
|
|
|
|
|
|
|
excludes => [qw/ StrictConstructor c3 /], |
62
|
|
|
|
|
|
|
includes => ['multi'], |
63
|
|
|
|
|
|
|
%args # you need this to allow customization of your customization |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# no need for a true value |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
And then use it: |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
package Some::Class { |
73
|
|
|
|
|
|
|
use My::Moose types => [qw/ArrayRef Num/]; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
param numbers ( isa => ArrayRef[Num] ); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
multi sub foo ($self) { ... } |
78
|
|
|
|
|
|
|
multi sub foo ($self, $bar) { ... } |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 DESCRIPTION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
I hate boilerplate, so let's get rid of it. Let's say you don't want L<namespace::autoclean> or |
84
|
|
|
|
|
|
|
C<carp>, but you do want C<multi>. Plus, you have custom versions of C<carp> and C<croak>: |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
package Some::Class { |
87
|
|
|
|
|
|
|
use MooseX::Extended |
88
|
|
|
|
|
|
|
excludes => [qw/ autoclean carp /], |
89
|
|
|
|
|
|
|
includes => ['multi']; |
90
|
|
|
|
|
|
|
use My::Carp q(carp croak); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
... my code here |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
You probably get tired of typing that every time. Now you don't have to. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
package My::Moose { |
98
|
|
|
|
|
|
|
use MooseX::Extended::Custom; |
99
|
|
|
|
|
|
|
use My::Carp (); |
100
|
|
|
|
|
|
|
use Import::Into; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub import { |
103
|
|
|
|
|
|
|
my ( $class, %args ) = @_; |
104
|
|
|
|
|
|
|
my $target_class = caller; |
105
|
|
|
|
|
|
|
MooseX::Extended::Custom->create( |
106
|
|
|
|
|
|
|
excludes => [qw/ autoclean carp /], |
107
|
|
|
|
|
|
|
includes => ['multi'], |
108
|
|
|
|
|
|
|
%args # you need this to allow customization of your customization |
109
|
|
|
|
|
|
|
); |
110
|
|
|
|
|
|
|
My::Carp->import::into($target_class, qw(carp croak)); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
And then when you use C<My::Moose>, that's all set up for you. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
If you need to change this on a "per class" basis: |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
use My::Moose |
119
|
|
|
|
|
|
|
excludes => ['carp'], |
120
|
|
|
|
|
|
|
types => [qw/ArrayRef Num/]; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
The above changes your C<excludes> and adds C<types>, but doesn't change your C<includes>. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 AUTHOR |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Curtis "Ovid" Poe <curtis.poe@gmail.com> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This software is Copyright (c) 2022 by Curtis "Ovid" Poe. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
This is free software, licensed under: |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |