X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FComponent.pm;h=da40d5cb35fd6cfdb754b6a36253413e459a16fa;hb=f7b672efdb91a057a449b353d157bb74761a2d94;hp=38e87aafcfa16b9282d8e1625089c04543702df8;hpb=b5ecfcf07b8ffe7e9984f0279c8781ce51c6ac6a;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Component.pm b/lib/Catalyst/Component.pm index 38e87aa..da40d5c 100644 --- a/lib/Catalyst/Component.pm +++ b/lib/Catalyst/Component.pm @@ -4,7 +4,7 @@ use strict; use base qw/Class::Accessor::Fast Class::Data::Inheritable/; use NEXT; -__PACKAGE__->mk_classdata($_) for qw/_config/; +__PACKAGE__->mk_classdata($_) for qw/_config _plugins/; =head1 NAME @@ -62,6 +62,31 @@ sub new { return $self->NEXT::new( { %{ $self->config }, %{$arguments} } ); } +=head2 COMPONENT($c) + +=cut + +sub COMPONENT { + my ( $self, $c ) = @_; + + # Temporary fix, some components does not pass context to constructor + my $arguments = ( ref( $_[-1] ) eq 'HASH' ) ? $_[-1] : {}; + + if ( my $new = $self->NEXT::COMPONENT( $c, $arguments ) ) { + return $new; + } + else { + if ( my $new = $self->new( $c, $arguments ) ) { + return $new; + } + else { + my $class = ref $self || $self; + my $new = { %{ $self->config }, %{$arguments} }; + return bless $new, $class; + } + } +} + # remember to leave blank lines between the consecutive =head2's # otherwise the pod tools don't recognize the subsequent =head2s