line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::ClassAttribute::Trait::Role::Composite; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2957
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
52
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.29'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
3
|
use Moose::Util::MetaRole; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
9
|
1
|
|
|
1
|
|
3
|
use Moose::Util qw(does_role); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
224
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
12
|
1
|
|
|
1
|
|
59
|
use Moose::Role; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
with 'MooseX::ClassAttribute::Trait::Role'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _merge_class_attributes { |
17
|
3
|
|
|
3
|
|
5
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
|
|
5
|
my @all_attributes; |
20
|
3
|
|
|
|
|
4
|
foreach my $role ( @{ $self->get_roles() } ) { |
|
3
|
|
|
|
|
90
|
|
21
|
6
|
100
|
|
|
|
92
|
if ( does_role( $role, 'MooseX::ClassAttribute::Trait::Role' ) ) { |
22
|
|
|
|
|
|
|
push @all_attributes, |
23
|
5
|
|
|
|
|
1032
|
map { $role->get_class_attribute($_) } |
|
5
|
|
|
|
|
186
|
|
24
|
|
|
|
|
|
|
$role->get_class_attribute_list(); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
3
|
|
|
|
|
4
|
my %seen; |
29
|
|
|
|
|
|
|
|
30
|
3
|
|
|
|
|
6
|
foreach my $attribute (@all_attributes) { |
31
|
5
|
|
|
|
|
19
|
my $name = $attribute->name(); |
32
|
|
|
|
|
|
|
|
33
|
5
|
50
|
|
|
|
11
|
if ( exists $seen{$name} ) { |
34
|
0
|
0
|
|
|
|
0
|
next if $seen{$name} == $attribute; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
require Moose; |
37
|
0
|
|
|
|
|
0
|
Moose->throw_error( "Role '" |
38
|
|
|
|
|
|
|
. $self->name() |
39
|
|
|
|
|
|
|
. "' has encountered a class attribute conflict " |
40
|
|
|
|
|
|
|
. "during composition. This is a fatal error and " |
41
|
|
|
|
|
|
|
. "cannot be disambiguated." ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
5
|
|
|
|
|
9
|
$seen{$name} = $attribute; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
3
|
|
|
|
|
3
|
foreach my $attribute (@all_attributes) { |
48
|
5
|
|
|
|
|
28
|
$self->add_class_attribute( $attribute->clone() ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
3
|
|
|
|
|
8
|
return keys %seen; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
around apply_params => sub { |
55
|
|
|
|
|
|
|
my $orig = shift; |
56
|
|
|
|
|
|
|
my $self = shift; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
$self->$orig(@_); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$self = Moose::Util::MetaRole::apply_metaroles( |
61
|
|
|
|
|
|
|
for => $self, |
62
|
|
|
|
|
|
|
role_metaroles => { |
63
|
|
|
|
|
|
|
application_to_class => |
64
|
|
|
|
|
|
|
['MooseX::ClassAttribute::Trait::Application::ToClass'], |
65
|
|
|
|
|
|
|
application_to_role => |
66
|
|
|
|
|
|
|
['MooseX::ClassAttribute::Trait::Application::ToRole'], |
67
|
|
|
|
|
|
|
}, |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$self->_merge_class_attributes(); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
return $self; |
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# ABSTRACT: A trait that supports applying multiple roles at once |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=pod |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=encoding UTF-8 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 NAME |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
MooseX::ClassAttribute::Trait::Role::Composite - A trait that supports applying multiple roles at once |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 VERSION |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
version 0.29 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 DESCRIPTION |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This trait is used to allow the application of multiple roles (one |
96
|
|
|
|
|
|
|
or more of which contain class attributes) to a class or role. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 BUGS |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
See L<MooseX::ClassAttribute> for details. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|http://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-ClassAttribute> |
103
|
|
|
|
|
|
|
(or L<bug-moosex-classattribute@rt.cpan.org|mailto:bug-moosex-classattribute@rt.cpan.org>). |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
I am also usually active on IRC as 'drolsky' on C<irc://irc.perl.org>. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 AUTHOR |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This software is Copyright (c) 2016 by Dave Rolsky. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This is free software, licensed under: |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |