bump version to 0.13
[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
12a0d4db 6our $VERSION = '0.13';
f77be127 7
88b7f2c8 8use namespace::autoclean;
9use Moose::Role;
10
63fcc508 11with 'MooseX::ClassAttribute::Trait::Application';
88b7f2c8 12
4cbcd0f0 13sub _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
411;
04b89789 42
43__END__
44
45=pod
46
47=head1 NAME
48
49MooseX::ClassAttribute::Trait::Application::ToClass - A trait that supports applying class attributes to classes
50
51=head1 DESCRIPTION
52
53This trait is used to allow the application of roles containing class
54attributes to classes.
55
56=head1 AUTHOR
57
58Dave Rolsky, C<< <autarch@urth.org> >>
59
60=head1 BUGS
61
62See L<MooseX::ClassAttribute> for details.
63
64=head1 COPYRIGHT & LICENSE
65
0cee5df4 66Copyright 2007-2010 Dave Rolsky, All Rights Reserved.
04b89789 67
68This program is free software; you can redistribute it and/or modify
69it under the same terms as Perl itself.
70
71=cut