package Catalyst::Component;
use Moose;
-use MooseX::ClassAttribute;
+use MooseX::Adopt::Class::Accessor::Fast;
use Catalyst::Utils;
-has _config => (
- is => 'rw',
- isa => 'HashRef',
- required => 1,
- default => {}
- );
-class_has _plugins => ( is => 'rw' );
+with 'MooseX::Emulate::Class::Accessor::Fast';
+with 'Catalyst::ClassData';
=head1 NAME
=cut
-#to do: are we switching to moose-style key => value constructors from
-# catalyst-style {key => value} constructors ?
+__PACKAGE__->mk_classdata($_) for qw/_config _plugins/;
around new => sub {
my $orig = shift;
# Temporary fix, some components does not pass context to constructor
my $arguments = ( ref( $_[-1] ) eq 'HASH' ) ? $_[-1] : {};
- my $merged = $self->merge_config_hashes( $self->config, $arguments ) );
- $orig->( $self, $merged );
-}
+
+ my $args = $self->merge_config_hashes( $self->config, $arguments );
+ return $self->$orig( $args );
+};
sub COMPONENT {
my ( $self, $c ) = @_;
# Temporary fix, some components does not pass context to constructor
my $arguments = ( ref( $_[-1] ) eq 'HASH' ) ? $_[-1] : {};
-
- #Moose TODO: I don't think I fully grok NEXT. is this here for MI or something?
- # how can we have a next here? this -is- the base class....
- 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;
- }
- }
+ $self->new($c, $arguments);
+
+# 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;
+# }
+# }
}
-#Moose TODO: I have no fucking clue what's going on here (groditi)
sub config {
my $self = shift;
my $config_sub = $self->can('_config');
- my $config = $self->$config_sub();
- #my $config = $self->_config;
+ my $config = $self->$config_sub() || {};
if (@_) {
my $newconfig = { %{@_ > 1 ? {@_} : $_[0]} };
$self->_config(
if ((my $config_sub_now = $self->can('_config')) ne $config_sub) {
- #this is retarded. if we want a new ref we could do: { %$config }
$config = $self->merge_config_hashes( $config, {} );
$self->$config_sub_now( $config );
}