1 package MooseX::ClassAttribute::Trait::Application::ToRole;
8 use Moose::Util::MetaRole;
9 use MooseX::ClassAttribute::Trait::Application::ToClass;
11 use namespace::autoclean;
14 with 'MooseX::ClassAttribute::Trait::Application';
16 sub _apply_class_attributes {
21 $role2 = Moose::Util::MetaRole::apply_metaclass_roles(
24 role => ['MooseX::ClassAttribute::Trait::Role'],
25 application_to_class =>
26 ['MooseX::ClassAttribute::Trait::Application::ToClass'],
27 application_to_role =>
28 ['MooseX::ClassAttribute::Trait::Application::ToRole'],
32 foreach my $attribute_name ( $role1->get_class_attribute_list() ) {
33 if ( $role2->has_class_attribute($attribute_name)
34 && $role2->get_class_attribute($attribute_name)
35 != $role1->get_class_attribute($attribute_name) ) {
38 Moose->throw_error( "Role '"
40 . "' has encountered a class attribute conflict "
41 . "during composition. This is fatal error and cannot be disambiguated."
45 $role2->add_class_attribute(
46 $role1->get_class_attribute($attribute_name)->clone() );
59 MooseX::ClassAttribute::Trait::Application::ToRole - A trait that supports applying class attributes to roles
63 This trait is used to allow the application of roles containing class
68 Dave Rolsky, C<< <autarch@urth.org> >>
72 See L<MooseX::ClassAttribute> for details.
74 =head1 COPYRIGHT & LICENSE
76 Copyright 2007-2010 Dave Rolsky, All Rights Reserved.
78 This program is free software; you can redistribute it and/or modify
79 it under the same terms as Perl itself.