X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FView%2FComponent%2FSubInclude.pm;h=fc7d649c3ebd6bf83ef733d185840af0a6cf29fb;hb=b454d9bb2c33864c114f3359fe2e1065133ec4cc;hp=efd8b33321677aae34e1f784f94b7cc219a5f16d;hpb=dcdc4ec85577543c2645b2290aa4fa0c0c74cc04;p=catagits%2FCatalyst-View-Component-SubInclude.git diff --git a/lib/Catalyst/View/Component/SubInclude.pm b/lib/Catalyst/View/Component/SubInclude.pm index efd8b33..fc7d649 100644 --- a/lib/Catalyst/View/Component/SubInclude.pm +++ b/lib/Catalyst/View/Component/SubInclude.pm @@ -19,7 +19,7 @@ Version 0.09 =cut -our $VERSION = '0.09'; +our $VERSION = '0.10'; $VERSION = eval $VERSION; =head1 SYNOPSIS @@ -116,6 +116,12 @@ has 'subinclude_plugin' => ( isa => Str, ); +has subinclude => ( + is => 'ro', + isa => HashRef, + default => sub { {} }, +); + around 'new' => sub { my $next = shift; my $class = shift; @@ -162,19 +168,23 @@ has _subinclude_plugin_class_instance_cache => ( sub _subinclude_plugin_class_instance { my ($self, $plugin) = @_; - my $class = $plugin =~ /::/ ? $plugin : __PACKAGE__ . '::' . $plugin; - my $cache = $self->_subinclude_plugin_class_instance_cache; return $cache->{$plugin} if exists $cache->{$plugin}; my $plugin_config = Catalyst::Utils::merge_hashes( - $self->config->{subinclude}->{ALL}||{}, - $self->config->{subinclude}->{$plugin}||{} + $self->subinclude->{ALL}||{}, + $self->subinclude->{$plugin}||{} ); + my $short_class = $plugin_config->{'class'} ? + delete $plugin_config->{'class'} + : $plugin; + my $class = $short_class =~ /::/ ? + $short_class + : __PACKAGE__ . '::' . $short_class; Class::MOP::load_class($class); - return $cache->{$plugin} = $class->new($plugin_config); + return $cache->{$class} = $class->new($plugin_config); } =head1 SEE ALSO