From: gfx Date: Tue, 17 Nov 2009 08:11:54 +0000 (+0900) Subject: Start to support "use Mouse -traits => ..." X-Git-Tag: 0.40_07~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=f12892e59f19c4ef3715bf79e0622582c7522fea Start to support "use Mouse -traits => ..." --- diff --git a/lib/Mouse/Exporter.pm b/lib/Mouse/Exporter.pm index 18a3387..ce5757d 100644 --- a/lib/Mouse/Exporter.pm +++ b/lib/Mouse/Exporter.pm @@ -149,7 +149,7 @@ sub do_import { my $arg = shift @args; if($arg =~ s/^-//){ if($arg eq 'traits'){ - push @traits, @{shift(@args)}; + push @traits, ref($args[0]) ? @{shift(@args)} : shift(@args); } else { Mouse::Util::not_supported("-$arg"); @@ -177,10 +177,11 @@ sub do_import { if(@traits){ my $type = (split /::/, ref $meta)[-1]; # e.g. "Class" for "My::Meta::Class" @traits = - map{ ref($_) ? $_ : Mouse::Util::resolve_metaclass_alias($type => $_, trait => 1) } - @traits; + map{ + ref($_) ? $_ + : Mouse::Util::resolve_metaclass_alias($type => $_, trait => 1) + } @traits; - not_supported('-traits'); require Mouse::Util::MetaRole; Mouse::Util::MetaRole::apply_metaclass_roles( for_class => $into, @@ -188,6 +189,9 @@ sub do_import { ); } } + elsif(@traits){ + Carp::confess("Cannot provide traits when $package does not have an init_meta() method"); + } if(@exports){ foreach my $keyword(@exports){