really fix MetaRole API use
[gitmo/MooseX-ClassAttribute.git] / lib / MooseX / ClassAttribute / Trait / Application / ToClass.pm
CommitLineData
63fcc508 1package MooseX::ClassAttribute::Trait::Application::ToClass;
88b7f2c8 2
3use strict;
4use warnings;
5
6use namespace::autoclean;
7use Moose::Role;
8
63fcc508 9with 'MooseX::ClassAttribute::Trait::Application';
88b7f2c8 10
4cbcd0f0 11sub _apply_class_attributes {
88b7f2c8 12 my $self = shift;
13 my $role = shift;
14 my $class = shift;
15
dbf3ee23 16 $class = Moose::Util::MetaRole::apply_metaroles(
88b7f2c8 17 for => $class,
18 class_metaroles => {
63fcc508 19 class => ['MooseX::ClassAttribute::Trait::Class'],
88b7f2c8 20 },
21 );
22
23 my $attr_metaclass = $class->attribute_metaclass();
24
25 foreach my $attribute_name ( $role->get_class_attribute_list() ) {
26 if ( $class->has_class_attribute($attribute_name)
27 && $class->get_class_attribute($attribute_name)
28 != $role->get_class_attribute($attribute_name) ) {
29 next;
30 }
31 else {
32 $class->add_class_attribute(
33 $role->get_class_attribute($attribute_name)
34 ->attribute_for_class($attr_metaclass) );
35 }
36 }
37}
38
391;
04b89789 40
0d0bf8c3 41# ABSTRACT: A trait that supports applying class attributes to classes
42
04b89789 43__END__
44
45=pod
46
04b89789 47=head1 DESCRIPTION
48
49This trait is used to allow the application of roles containing class
50attributes to classes.
51
04b89789 52=head1 BUGS
53
54See L<MooseX::ClassAttribute> for details.
55
04b89789 56=cut