X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FComponent.pm;h=feab1cf8a59684c2c71168c6e01620716cb5f6b6;hp=38e87aafcfa16b9282d8e1625089c04543702df8;hb=22247e54ccd3fbdaf286e77304b96e61ecc43a0f;hpb=2666dd3ba45edb0fa31508f67d94fe80072f94f6 diff --git a/lib/Catalyst/Component.pm b/lib/Catalyst/Component.pm index 38e87aa..feab1cf 100644 --- a/lib/Catalyst/Component.pm +++ b/lib/Catalyst/Component.pm @@ -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