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