line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mouse::Meta::Role; |
2
|
282
|
|
|
282
|
|
1402
|
use Mouse::Util qw(:meta); # enables strict and warnings |
|
282
|
|
|
|
|
302
|
|
|
282
|
|
|
|
|
1259
|
|
3
|
|
|
|
|
|
|
|
4
|
282
|
|
|
282
|
|
1088
|
use Mouse::Meta::Module; |
|
282
|
|
|
|
|
326
|
|
|
282
|
|
|
|
|
159174
|
|
5
|
|
|
|
|
|
|
our @ISA = qw(Mouse::Meta::Module); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub method_metaclass; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub _construct_meta { |
10
|
264
|
|
|
264
|
|
2383
|
my $class = shift; |
11
|
|
|
|
|
|
|
|
12
|
264
|
|
|
|
|
2613
|
my %args = @_; |
13
|
|
|
|
|
|
|
|
14
|
264
|
|
|
|
|
2512
|
$args{methods} = {}; |
15
|
264
|
|
|
|
|
2487
|
$args{attributes} = {}; |
16
|
264
|
|
|
|
|
2455
|
$args{required_methods} = []; |
17
|
264
|
|
|
|
|
2420
|
$args{roles} = []; |
18
|
|
|
|
|
|
|
|
19
|
264
|
|
33
|
|
|
3117
|
my $self = bless \%args, ref($class) || $class; |
20
|
264
|
100
|
|
|
|
2645
|
if($class ne __PACKAGE__){ |
21
|
58
|
|
|
|
|
935
|
$self->meta->_initialize_object($self, \%args); |
22
|
|
|
|
|
|
|
} |
23
|
264
|
|
|
|
|
7384
|
return $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub create_anon_role{ |
27
|
68
|
|
|
68
|
0
|
26906
|
my $self = shift; |
28
|
68
|
|
|
|
|
2422
|
return $self->create(undef, @_); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub is_anon_role; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub get_roles; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub calculate_all_roles { |
36
|
12
|
|
|
12
|
0
|
17
|
my $self = shift; |
37
|
12
|
|
|
|
|
9
|
my %seen; |
38
|
14
|
|
|
|
|
66
|
return grep { !$seen{ $_->name }++ } |
39
|
12
|
|
|
|
|
10
|
($self, map { $_->calculate_all_roles } @{ $self->get_roles }); |
|
2
|
|
|
|
|
4
|
|
|
12
|
|
|
|
|
26
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub get_required_method_list{ |
43
|
162
|
|
|
162
|
0
|
2275
|
return @{ $_[0]->{required_methods} }; |
|
162
|
|
|
|
|
6937
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub add_required_methods { |
47
|
180
|
|
|
180
|
0
|
2430
|
my($self, @methods) = @_; |
48
|
180
|
|
|
|
|
2314
|
my %required = map{ $_ => 1 } @{$self->{required_methods}}; |
|
23
|
|
|
|
|
51
|
|
|
180
|
|
|
|
|
4778
|
|
49
|
180
|
|
100
|
|
|
2336
|
push @{$self->{required_methods}}, grep{ !$required{$_}++ && !$self->has_method($_) } @methods; |
|
180
|
|
|
|
|
4520
|
|
|
71
|
|
|
|
|
320
|
|
50
|
180
|
|
|
|
|
7017
|
return; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub requires_method { |
54
|
10
|
|
|
10
|
0
|
559
|
my($self, $name) = @_; |
55
|
10
|
|
|
|
|
12
|
return scalar( grep{ $_ eq $name } @{ $self->{required_methods} } ) != 0; |
|
8
|
|
|
|
|
37
|
|
|
10
|
|
|
|
|
25
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub add_attribute { |
59
|
88
|
|
|
88
|
0
|
604
|
my $self = shift; |
60
|
88
|
|
|
|
|
95
|
my $name = shift; |
61
|
|
|
|
|
|
|
|
62
|
88
|
100
|
|
|
|
391
|
$self->{attributes}->{$name} = (@_ == 1) ? $_[0] : { @_ }; |
63
|
88
|
|
|
|
|
193
|
return; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub apply { |
67
|
302
|
|
|
302
|
0
|
3122
|
my $self = shift; |
68
|
302
|
|
|
|
|
3053
|
my $consumer = shift; |
69
|
|
|
|
|
|
|
|
70
|
302
|
|
|
|
|
41012
|
require 'Mouse/Meta/Role/Application.pm'; |
71
|
302
|
|
|
|
|
3841
|
return Mouse::Meta::Role::Application->new(@_)->apply($self, $consumer); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub combine { |
75
|
52
|
|
|
52
|
0
|
811
|
my($self, @role_specs) = @_; |
76
|
|
|
|
|
|
|
|
77
|
52
|
|
|
|
|
11331
|
require 'Mouse/Meta/Role/Composite.pm'; |
78
|
52
|
|
|
|
|
939
|
return Mouse::Meta::Role::Composite->new(roles => \@role_specs); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub add_before_method_modifier; |
82
|
|
|
|
|
|
|
sub add_around_method_modifier; |
83
|
|
|
|
|
|
|
sub add_after_method_modifier; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub get_before_method_modifiers; |
86
|
|
|
|
|
|
|
sub get_around_method_modifiers; |
87
|
|
|
|
|
|
|
sub get_after_method_modifiers; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub add_override_method_modifier{ |
90
|
16
|
|
|
16
|
0
|
22
|
my($self, $method_name, $method) = @_; |
91
|
|
|
|
|
|
|
|
92
|
16
|
100
|
|
|
|
45
|
if($self->has_method($method_name)){ |
93
|
|
|
|
|
|
|
# This error happens in the override keyword or during role composition, |
94
|
|
|
|
|
|
|
# so I added a message, "A local method of ...", only for compatibility (gfx) |
95
|
2
|
|
|
|
|
15
|
$self->throw_error("Cannot add an override of method '$method_name' " |
96
|
|
|
|
|
|
|
. "because there is a local version of '$method_name'" |
97
|
|
|
|
|
|
|
. "(A local method of the same name as been found)"); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
14
|
|
|
|
|
41
|
$self->{override_method_modifiers}->{$method_name} = $method; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub get_override_method_modifier { |
104
|
2
|
|
|
2
|
0
|
6415
|
my ($self, $method_name) = @_; |
105
|
2
|
|
|
|
|
9
|
return $self->{override_method_modifiers}->{$method_name}; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub does_role { |
109
|
1003
|
|
|
1003
|
0
|
9023
|
my ($self, $role_name) = @_; |
110
|
|
|
|
|
|
|
|
111
|
1003
|
50
|
|
|
|
7866
|
(defined $role_name) |
112
|
|
|
|
|
|
|
|| $self->throw_error("You must supply a role name to look for"); |
113
|
|
|
|
|
|
|
|
114
|
1003
|
100
|
|
|
|
8105
|
$role_name = $role_name->name if ref $role_name; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# if we are it,.. then return true |
117
|
1003
|
100
|
|
|
|
15331
|
return 1 if $role_name eq $self->name; |
118
|
|
|
|
|
|
|
# otherwise.. check our children |
119
|
716
|
|
|
|
|
5529
|
for my $role (@{ $self->get_roles }) { |
|
716
|
|
|
|
|
11190
|
|
120
|
499
|
100
|
|
|
|
2939
|
return 1 if $role->does_role($role_name); |
121
|
|
|
|
|
|
|
} |
122
|
444
|
|
|
|
|
8907
|
return 0; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; |
126
|
|
|
|
|
|
|
__END__ |