line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mouse::Role; |
2
|
92
|
|
|
251
|
|
840657
|
use Mouse::Exporter; # enables strict and warnings |
|
92
|
|
|
|
|
142
|
|
|
92
|
|
|
|
|
428
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = 'v2.4.8'; |
5
|
|
|
|
|
|
|
|
6
|
92
|
|
|
135
|
|
350
|
use Carp (); |
|
92
|
|
|
|
|
93
|
|
|
92
|
|
|
|
|
1035
|
|
7
|
92
|
|
|
135
|
|
281
|
use Scalar::Util (); |
|
92
|
|
|
|
|
84
|
|
|
92
|
|
|
|
|
998
|
|
8
|
|
|
|
|
|
|
|
9
|
92
|
|
|
132
|
|
4566
|
use Mouse (); |
|
92
|
|
|
|
|
136
|
|
|
92
|
|
|
|
|
42611
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Mouse::Exporter->setup_import_methods( |
12
|
|
|
|
|
|
|
as_is => [qw( |
13
|
|
|
|
|
|
|
extends with |
14
|
|
|
|
|
|
|
has |
15
|
|
|
|
|
|
|
before after around |
16
|
|
|
|
|
|
|
override super |
17
|
|
|
|
|
|
|
augment inner |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
requires excludes |
20
|
|
|
|
|
|
|
), |
21
|
|
|
|
|
|
|
\&Scalar::Util::blessed, |
22
|
|
|
|
|
|
|
\&Carp::confess, |
23
|
|
|
|
|
|
|
], |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub extends { |
28
|
2
|
|
|
42
|
0
|
821
|
Carp::croak "Roles do not support 'extends'"; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub with { |
32
|
36
|
|
|
76
|
0
|
8893
|
Mouse::Util::apply_all_roles(scalar(caller), @_); |
33
|
33
|
|
|
|
|
72
|
return; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub has { |
37
|
59
|
|
|
98
|
0
|
6442
|
my $meta = Mouse::Meta::Role->initialize(scalar caller); |
38
|
59
|
|
|
|
|
109
|
my $name = shift; |
39
|
|
|
|
|
|
|
|
40
|
59
|
50
|
|
|
|
927
|
$meta->throw_error(q{Usage: has 'name' => ( key => value, ... )}) |
41
|
|
|
|
|
|
|
if @_ % 2; # odd number of arguments |
42
|
|
|
|
|
|
|
|
43
|
59
|
100
|
|
|
|
178
|
for my $n(ref($name) ? @{$name} : $name){ |
|
1
|
|
|
|
|
3
|
|
44
|
61
|
|
|
|
|
278
|
$meta->add_attribute($n => @_); |
45
|
|
|
|
|
|
|
} |
46
|
59
|
|
|
|
|
180
|
return; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub before { |
50
|
8
|
|
|
47
|
0
|
1961
|
my $meta = Mouse::Meta::Role->initialize(scalar caller); |
51
|
8
|
|
|
|
|
14
|
my $code = pop; |
52
|
8
|
|
|
|
|
123
|
for my $name($meta->_collect_methods(@_)) { |
53
|
7
|
|
|
|
|
91
|
$meta->add_before_method_modifier($name => $code); |
54
|
|
|
|
|
|
|
} |
55
|
7
|
|
|
|
|
16
|
return; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub after { |
59
|
12
|
|
|
12
|
0
|
518
|
my $meta = Mouse::Meta::Role->initialize(scalar caller); |
60
|
12
|
|
|
|
|
28
|
my $code = pop; |
61
|
12
|
|
|
|
|
59
|
for my $name($meta->_collect_methods(@_)) { |
62
|
11
|
|
|
|
|
86
|
$meta->add_after_method_modifier($name => $code); |
63
|
|
|
|
|
|
|
} |
64
|
11
|
|
|
|
|
22
|
return; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub around { |
68
|
12
|
|
|
12
|
0
|
872
|
my $meta = Mouse::Meta::Role->initialize(scalar caller); |
69
|
12
|
|
|
|
|
26
|
my $code = pop; |
70
|
12
|
|
|
|
|
68
|
for my $name($meta->_collect_methods(@_)) { |
71
|
12
|
|
|
|
|
122
|
$meta->add_around_method_modifier($name => $code); |
72
|
|
|
|
|
|
|
} |
73
|
11
|
|
|
|
|
28
|
return; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub super { |
78
|
12
|
50
|
|
12
|
0
|
45
|
return if !defined $Mouse::SUPER_BODY; |
79
|
12
|
|
|
|
|
23
|
$Mouse::SUPER_BODY->(@Mouse::SUPER_ARGS); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub override { |
83
|
|
|
|
|
|
|
# my($name, $code) = @_; |
84
|
9
|
|
|
9
|
0
|
72
|
Mouse::Meta::Role->initialize(scalar caller)->add_override_method_modifier(@_); |
85
|
8
|
|
|
|
|
13
|
return; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# We keep the same errors messages as Moose::Role emits, here. |
89
|
|
|
|
|
|
|
sub inner { |
90
|
1
|
|
|
1
|
0
|
529
|
Carp::croak "Roles cannot support 'inner'"; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub augment { |
94
|
1
|
|
|
1
|
0
|
958
|
Carp::croak "Roles cannot support 'augment'"; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub requires { |
98
|
21
|
|
|
21
|
1
|
1217
|
my $meta = Mouse::Meta::Role->initialize(scalar caller); |
99
|
21
|
50
|
|
|
|
69
|
$meta->throw_error("Must specify at least one method") unless @_; |
100
|
21
|
|
|
|
|
713
|
$meta->add_required_methods(@_); |
101
|
21
|
|
|
|
|
30
|
return; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub excludes { |
105
|
1
|
|
|
1
|
1
|
338
|
Mouse::Util::not_supported(); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub init_meta{ |
109
|
200
|
|
|
200
|
0
|
182
|
shift; |
110
|
200
|
|
|
|
|
423
|
my %args = @_; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
my $class = $args{for_class} |
113
|
200
|
50
|
|
|
|
435
|
or Carp::confess("Cannot call init_meta without specifying a for_class"); |
114
|
|
|
|
|
|
|
|
115
|
200
|
|
50
|
|
|
784
|
my $metaclass = $args{metaclass} || 'Mouse::Meta::Role'; |
116
|
|
|
|
|
|
|
|
117
|
200
|
|
|
|
|
1122
|
my $meta = $metaclass->initialize($class); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
$meta->add_method(meta => sub{ |
120
|
93
|
|
33
|
93
|
|
23195
|
$metaclass->initialize(ref($_[0]) || $_[0]); |
|
|
|
|
93
|
|
|
|
|
|
|
|
70
|
|
|
|
121
|
200
|
|
|
|
|
2382
|
}); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# make a role type for each Mouse role |
124
|
200
|
100
|
|
|
|
530
|
Mouse::Util::TypeConstraints::role_type($class) |
125
|
|
|
|
|
|
|
unless Mouse::Util::TypeConstraints::find_type_constraint($class); |
126
|
|
|
|
|
|
|
|
127
|
200
|
|
|
|
|
583
|
return $meta; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
__END__ |