From: Graham Knop Date: Mon, 13 May 2013 19:46:43 +0000 (-0400) Subject: properly die when composing a non-Role module X-Git-Tag: v1.003000~85 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c316ebe58b5d4bb3f9b80bda4320a11730b71d19;p=gitmo%2FMoo.git properly die when composing a non-Role module --- diff --git a/Changes b/Changes index 3afb48c..c589623 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,5 @@ + - properly die when composing a module that isn't a Role + 1.002000 - 2013-05-04 - add 'moosify' attribute key to provide code for inflating to Moose - fix warnings about unknown attribute parameters on metaclass inflation diff --git a/lib/Moo/Role.pm b/lib/Moo/Role.pm index 0fc16b8..72c5659 100644 --- a/lib/Moo/Role.pm +++ b/lib/Moo/Role.pm @@ -99,10 +99,12 @@ sub _inhale_if_moose { and ( $INC{"Moose.pm"} and $meta = Class::MOP::class_of($role) + and $meta->isa('Moose::Meta::Role') ) or ( Mouse::Util->can('find_meta') and $meta = Mouse::Util::find_meta($role) + and $meta->isa('Mouse::Meta::Role') ) ) { $INFO{$role}{methods} = { @@ -210,6 +212,7 @@ sub apply_roles_to_package { sub apply_single_role_to_package { my ($me, $to, $role) = @_; + die "${role} is not a Moo::Role" unless my $info = $INFO{$role}; $me->_inhale_if_moose($role); $me->_handle_constructor($to, $INFO{$role}{attributes}); $me->_maybe_make_accessors($role, $to);