X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FAttribute.pm;h=137d139c7dc39fd71e77c498bc921f94fc30a7f1;hb=ae7820b1b884344a7ee90d94b484ca46459eb7b1;hp=738900f3e31bfec795f65ca9182d8cbd60a1d1e8;hpb=2e7576bdd6c4a179beadc2d21623c6cad1d66469;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index 738900f..137d139 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -9,7 +9,7 @@ use List::MoreUtils 'any'; use Try::Tiny; use overload (); -our $VERSION = '0.96'; +our $VERSION = '1.06'; our $AUTHORITY = 'cpan:STEVAN'; use Moose::Meta::Method::Accessor; @@ -659,23 +659,25 @@ sub _canonicalize_handles { elsif (blessed($handles) && $handles->isa('Moose::Meta::TypeConstraint::DuckType')) { return map { $_ => $_ } @{ $handles->methods }; } + elsif (blessed($handles) && $handles->isa('Moose::Meta::TypeConstraint::Role')) { + $handles = $handles->role; + } else { $self->throw_error("Unable to canonicalize the 'handles' option with $handles", data => $handles); } } - else { - Class::MOP::load_class($handles); - my $role_meta = Class::MOP::class_of($handles); - (blessed $role_meta && $role_meta->isa('Moose::Meta::Role')) - || $self->throw_error("Unable to canonicalize the 'handles' option with $handles because its metaclass is not a Moose::Meta::Role", data => $handles); + Class::MOP::load_class($handles); + my $role_meta = Class::MOP::class_of($handles); - return map { $_ => $_ } - grep { $_ ne 'meta' } ( - $role_meta->get_method_list, - map { $_->name } $role_meta->get_required_method_list, - ); - } + (blessed $role_meta && $role_meta->isa('Moose::Meta::Role')) + || $self->throw_error("Unable to canonicalize the 'handles' option with $handles because its metaclass is not a Moose::Meta::Role", data => $handles); + + return map { $_ => $_ } + grep { $_ ne 'meta' } ( + $role_meta->get_method_list, + map { $_->name } $role_meta->get_required_method_list, + ); } sub _find_delegate_metaclass { @@ -684,7 +686,7 @@ sub _find_delegate_metaclass { # we might be dealing with a non-Moose class, # and need to make our own metaclass. if there's # already a metaclass, it will be returned - return Moose::Meta::Class->initialize($class); + return Class::MOP::Class->initialize($class); } elsif (my $role = $self->_does_metadata) { return Class::MOP::class_of($role); @@ -942,7 +944,7 @@ I Before setting the value, a check is made on the type constraint of the attribute, if it has one, to see if the value passes it. If the -value fails to pass, the set operation dies with a L. +value fails to pass, the set operation dies with a L. Any coercion to convert values is done before checking the type constraint.