Commit | Line | Data |
63fcc508 |
1 | package MooseX::ClassAttribute::Trait::Application::ToClass; |
88b7f2c8 |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
88412c09 |
6 | our $VERSION = '0.11'; |
f77be127 |
7 | |
88b7f2c8 |
8 | use namespace::autoclean; |
9 | use Moose::Role; |
10 | |
63fcc508 |
11 | with 'MooseX::ClassAttribute::Trait::Application'; |
88b7f2c8 |
12 | |
4cbcd0f0 |
13 | sub _apply_class_attributes { |
88b7f2c8 |
14 | my $self = shift; |
15 | my $role = shift; |
16 | my $class = shift; |
17 | |
18 | $class = Moose::Util::MetaRole::apply_metaclass_roles( |
19 | for => $class, |
20 | class_metaroles => { |
63fcc508 |
21 | class => ['MooseX::ClassAttribute::Trait::Class'], |
88b7f2c8 |
22 | }, |
23 | ); |
24 | |
25 | my $attr_metaclass = $class->attribute_metaclass(); |
26 | |
27 | foreach my $attribute_name ( $role->get_class_attribute_list() ) { |
28 | if ( $class->has_class_attribute($attribute_name) |
29 | && $class->get_class_attribute($attribute_name) |
30 | != $role->get_class_attribute($attribute_name) ) { |
31 | next; |
32 | } |
33 | else { |
34 | $class->add_class_attribute( |
35 | $role->get_class_attribute($attribute_name) |
36 | ->attribute_for_class($attr_metaclass) ); |
37 | } |
38 | } |
39 | } |
40 | |
41 | 1; |
04b89789 |
42 | |
43 | __END__ |
44 | |
45 | =pod |
46 | |
47 | =head1 NAME |
48 | |
49 | MooseX::ClassAttribute::Trait::Application::ToClass - A trait that supports applying class attributes to classes |
50 | |
51 | =head1 DESCRIPTION |
52 | |
53 | This trait is used to allow the application of roles containing class |
54 | attributes to classes. |
55 | |
56 | =head1 AUTHOR |
57 | |
58 | Dave Rolsky, C<< <autarch@urth.org> >> |
59 | |
60 | =head1 BUGS |
61 | |
62 | See L<MooseX::ClassAttribute> for details. |
63 | |
64 | =head1 COPYRIGHT & LICENSE |
65 | |
66 | Copyright 2007-2008 Dave Rolsky, All Rights Reserved. |
67 | |
68 | This program is free software; you can redistribute it and/or modify |
69 | it under the same terms as Perl itself. |
70 | |
71 | =cut |