privatize apply_class_attributes and update pod coverage exclusions
[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
16 $class = Moose::Util::MetaRole::apply_metaclass_roles(
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
41__END__
42
43=pod
44
45=head1 NAME
46
47MooseX::ClassAttribute::Trait::Application::ToClass - A trait that supports applying class attributes to classes
48
49=head1 DESCRIPTION
50
51This trait is used to allow the application of roles containing class
52attributes to classes.
53
54=head1 AUTHOR
55
56Dave Rolsky, C<< <autarch@urth.org> >>
57
58=head1 BUGS
59
60See L<MooseX::ClassAttribute> for details.
61
62=head1 COPYRIGHT & LICENSE
63
64Copyright 2007-2008 Dave Rolsky, All Rights Reserved.
65
66This program is free software; you can redistribute it and/or modify
67it under the same terms as Perl itself.
68
69=cut