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=876f682da6c0dc47878823c42812d2062a89153e;hp=116aa9ad8dab10a71f01adf705a69f49d0f6502a;hb=4090e3bb3fea1a73ac369250e31584d61428b808;hpb=e8b9f2a92084b3b9dab6b2b879900481b8548b3b diff --git a/lib/Catalyst/Component.pm b/lib/Catalyst/Component.pm index 116aa9a..876f682 100644 --- a/lib/Catalyst/Component.pm +++ b/lib/Catalyst/Component.pm @@ -1,10 +1,12 @@ package Catalyst::Component; -use strict; -use base qw/Class::Accessor::Fast Class::Data::Inheritable/; -use NEXT; +use Moose; +use MooseX::Adopt::Class::Accessor::Fast; use Catalyst::Utils; +with 'MooseX::Emulate::Class::Accessor::Fast'; +with 'Catalyst::ClassData'; + =head1 NAME @@ -51,38 +53,24 @@ component loader with config() support and a process() method placeholder. __PACKAGE__->mk_classdata($_) for qw/_config _plugins/; - - -sub new { - my ( $self, $c ) = @_; +around new => sub { + my ( $orig, $self) = @_; # Temporary fix, some components does not pass context to constructor my $arguments = ( ref( $_[-1] ) eq 'HASH' ) ? $_[-1] : {}; - return $self->NEXT::new( - $self->merge_config_hashes( $self->config, $arguments ) ); -} + my $args = $self->merge_config_hashes( $self->config, $arguments ); + $self->$orig( $args ); +}; + +no Moose; 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->merge_config_hashes( - $self->config, $arguments ); - return bless $new, $class; - } - } + return $self->new($c, $arguments); } sub config {