| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
|
3
|
21
|
|
|
21
|
|
95346
|
|
|
|
21
|
|
|
|
|
54
|
|
|
|
21
|
|
|
|
|
132
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2019'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Moo::Role; |
|
7
|
21
|
|
|
21
|
|
145
|
use namespace::clean; |
|
|
21
|
|
|
|
|
42
|
|
|
|
21
|
|
|
|
|
114
|
|
|
8
|
21
|
|
|
21
|
|
6992
|
|
|
|
21
|
|
|
|
|
60
|
|
|
|
21
|
|
|
|
|
135
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
16
|
|
|
16
|
1
|
1789
|
my $class = shift; |
|
11
|
|
|
|
|
|
|
$class = ref $class || $class; |
|
12
|
|
|
|
|
|
|
my @plugins = ref $_[0] eq 'ARRAY' ? @{$_[0]} : @_; |
|
13
|
15
|
|
|
15
|
1
|
24
|
@plugins = split /,/, join ',', @plugins; |
|
14
|
15
|
|
66
|
|
|
46
|
@plugins || return $class; |
|
15
|
15
|
50
|
|
|
|
55
|
my $ns = $class->plugin_namespace; |
|
|
0
|
|
|
|
|
0
|
|
|
16
|
15
|
|
|
|
|
59
|
Moo::Role->create_class_with_roles( |
|
17
|
15
|
50
|
|
|
|
35
|
$class, |
|
18
|
15
|
|
|
|
|
50
|
map { |
|
19
|
|
|
|
|
|
|
my $pkg = $_; |
|
20
|
|
|
|
|
|
|
if ($pkg !~ s/^\+// && $pkg !~ /^$ns/) { |
|
21
|
|
|
|
|
|
|
$pkg = "${ns}::${pkg}"; |
|
22
|
15
|
|
|
|
|
30
|
} |
|
|
16
|
|
|
|
|
32
|
|
|
23
|
16
|
50
|
33
|
|
|
138
|
$pkg; |
|
24
|
16
|
|
|
|
|
46
|
} @plugins |
|
25
|
|
|
|
|
|
|
); |
|
26
|
16
|
|
|
|
|
75
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=pod |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 NAME |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Catmandu::Pluggable - A role for classes that need plugin capabilities |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
package My::Foo::Bar; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
use Role::Tiny; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
before foo => sub { |
|
44
|
|
|
|
|
|
|
print "Before foo!\n"; |
|
45
|
|
|
|
|
|
|
}; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
after foo => sub { |
|
48
|
|
|
|
|
|
|
print "After foo!\n"; |
|
49
|
|
|
|
|
|
|
}; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub extra { |
|
52
|
|
|
|
|
|
|
print "I can do extra too\n"; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
package My::Foo; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
use Moo; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
with 'Catmandu::Pluggable'; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub plugin_namespace { |
|
62
|
|
|
|
|
|
|
'My::Foo'; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub foo { |
|
66
|
|
|
|
|
|
|
print "Foo!\n"; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
package main; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $x = My::Foo->with_plugins('Bar')->new; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# prints: |
|
74
|
|
|
|
|
|
|
# Before foo! |
|
75
|
|
|
|
|
|
|
# Foo! |
|
76
|
|
|
|
|
|
|
# After foo! |
|
77
|
|
|
|
|
|
|
$x->foo; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# prints: |
|
80
|
|
|
|
|
|
|
# I can do extra too |
|
81
|
|
|
|
|
|
|
$x->extra; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 METHODS |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 plugin_namespace |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Returns the namespace where all plugins for your class can be found. |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 with_plugins(NAME) |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 with_plugins(NAME,NAME,...) |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This class method returns a subclass of your class with all provided plugins NAME-s implemented. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
L<Catmandu::Bag>, |
|
98
|
|
|
|
|
|
|
L<Catmandu::Plugin::Datestamps>, |
|
99
|
|
|
|
|
|
|
L<Catmandu::Plugin::Versioning> |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |