X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst.pm;h=c131008a189c9e9cd36ec3144e1a828fb265e64c;hp=a994166ef81e2181540ccd03c56a5f6f9ecfd31f;hb=e5210a95f78613a598abbfc7d29d92605d5bbad0;hpb=c49128b19ce9fa7afa95ccf9e95da00f74569ab5 diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index a994166..c131008 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -2479,9 +2479,6 @@ the plugin name does not begin with C. my ( $proto, $plugin, $instant ) = @_; my $class = ref $proto || $proto; - # no ignore_loaded here, the plugin may already have been - # defined in memory and we don't want to error on "no file" if so - Class::MOP::load_class( $plugin ); $proto->_plugins->{$plugin} = 1; @@ -2502,14 +2499,27 @@ the plugin name does not begin with C. $class->_plugins( {} ) unless $class->_plugins; $plugins ||= []; - for my $plugin ( reverse @$plugins ) { - unless ( $plugin =~ s/\A\+// ) { - $plugin = "Catalyst::Plugin::$plugin"; - } + my @plugins = map { s/\A\+// ? $_ : "Catalyst::Plugin::$_" } @$plugins; + + Class::MOP::load_class($_) for @plugins; + + for my $plugin ( reverse @plugins ) { + my $meta = find_meta($plugin); + next if $meta && $meta->isa('Moose::Meta::Role'); $class->_register_plugin($plugin); } + + my @roles = + map { $_->name } + grep { $_ && blessed($_) && $_->isa('Moose::Meta::Role') } + map { find_meta($_) } + @plugins; + + Moose::Util::apply_all_roles( + $class => @roles + ) if @roles; } }