X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FRole%2FApplication%2FRoleSummation.pm;h=3b5c27e87e92e0f44991ce513e5e89b96ee29db2;hb=757d0de5eaf1c172e6c17a7f257c34424f05d629;hp=d5b5e7219dd0a01fa54cdbce8e2cd4598fba3c23;hpb=c8b8d92f366e6d9c09c0bb2a54b4f1942fc665ef;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Role/Application/RoleSummation.pm b/lib/Moose/Meta/Role/Application/RoleSummation.pm index d5b5e72..3b5c27e 100644 --- a/lib/Moose/Meta/Role/Application/RoleSummation.pm +++ b/lib/Moose/Meta/Role/Application/RoleSummation.pm @@ -8,7 +8,7 @@ use Scalar::Util 'blessed'; use Moose::Meta::Role::Composite; -our $VERSION = '0.89'; +our $VERSION = '1.17'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -116,30 +116,36 @@ sub check_required_attributes { sub apply_attributes { my ($self, $c) = @_; - my @all_attributes = map { - my $role = $_; - map { - +{ - name => $_, - attr => $role->get_attribute($_), - } - } $role->get_attribute_list - } @{$c->get_roles}; + my @all_attributes; + + for my $role ( @{ $c->get_roles } ) { + push @all_attributes, + map { $role->get_attribute($_) } $role->get_attribute_list; + } my %seen; foreach my $attr (@all_attributes) { - if (exists $seen{$attr->{name}}) { - if ( $seen{$attr->{name}} != $attr->{attr} ) { - require Moose; - Moose->throw_error("We have encountered an attribute conflict with '" . $attr->{name} . "' " - . "during composition. This is fatal error and cannot be disambiguated.") - } + my $name = $attr->name; + + if ( exists $seen{$name} ) { + next if $seen{$name}->is_same_as($attr); + + my $role1 = $seen{$name}->associated_role->name; + my $role2 = $attr->associated_role->name; + + require Moose; + Moose->throw_error( + "We have encountered an attribute conflict with '$name' " + . "during role composition. " + . " This attribute is defined in both $role1 and $role2." + . " This is fatal error and cannot be disambiguated." ); } - $seen{$attr->{name}} = $attr->{attr}; + + $seen{$name} = $attr; } foreach my $attr (@all_attributes) { - $c->add_attribute($attr->{name}, $attr->{attr}); + $c->add_attribute( $attr->clone ); } } @@ -158,7 +164,9 @@ sub apply_methods { name => $_, method => $role->get_method($_), } - } $role->get_method_list), + } map { $_->name } + grep { !$_->isa('Class::MOP::Method::Meta') } + $role->_get_local_methods), (map { +{ role => $role, @@ -299,9 +307,7 @@ bindings and 'disabling' the conflicting bindings =head1 BUGS -All complex software has bugs lurking in it, and this module is no -exception. If you find a bug please either email me, or add the bug -to cpan-RT. +See L for details on reporting bugs. =head1 AUTHOR @@ -309,7 +315,7 @@ Stevan Little Estevan@iinteractive.comE =head1 COPYRIGHT AND LICENSE -Copyright 2006-2009 by Infinity Interactive, Inc. +Copyright 2006-2010 by Infinity Interactive, Inc. L