Commit a failing test for components getting config from self. This is a showstopper...
Tomas Doran [Mon, 28 Jul 2008 20:39:00 +0000 (20:39 +0000)]
Changes
Makefile.PL
lib/Catalyst/Component.pm
lib/Catalyst/Model.pm
t/lib/TestApp/Model/Foo.pm
t/unit_core_component_layers.t

diff --git a/Changes b/Changes
index 95f397b..8903baa 100644 (file)
--- a/Changes
+++ b/Changes
@@ -3,6 +3,7 @@
 5.8000
         - Port to Moose
         - Added test for action stringify
+        - Added test for component instances getting $self->{value} from config.
 
 5.7013
         - Fix subdirs for scripts that run in subdirs more than one level deep.
index d785b4a..62a7279 100644 (file)
@@ -7,7 +7,7 @@ name 'Catalyst-Runtime';
 all_from 'lib/Catalyst/Runtime.pm';
 
 requires 'MooseX::Emulate::Class::Accessor::Fast';
-
+requires 'Moose' => '0.51';
 requires 'Carp';
 requires 'Class::Accessor::Fast';
 requires 'Class::Data::Inheritable';
index 68dbcdb..1f1fbb5 100644 (file)
@@ -57,15 +57,16 @@ component loader with config() support and a process() method placeholder.
 __PACKAGE__->mk_classdata('_plugins');
 __PACKAGE__->mk_classdata('_config');
 
-around new => sub {
-    my ( $orig, $self) = @_;
-
+sub BUILDARGS {
+    my ($self) = @_;
+    
     # Temporary fix, some components does not pass context to constructor
     my $arguments = ( ref( $_[-1] ) eq 'HASH' ) ? $_[-1] : {};
 
     my $args =  $self->merge_config_hashes( $self->config, $arguments );
-    $self->$orig( $args );
-};
+    
+    return $args;
+}
 
 no Moose;
 
index 4ab2ebc..f573770 100644 (file)
@@ -5,9 +5,6 @@ extends qw/Catalyst::Component/;
 
 no Moose;
 
-#We can't immutablize anything that ISA Component just yet
-#__PACKAGE__->meta->make_immutable();
-
 =head1 NAME
 
 Catalyst::Model - Catalyst Model base class
index b0418e8..d4af11c 100644 (file)
@@ -5,8 +5,12 @@ use warnings;
 
 use base qw/ Catalyst::Model /;
 
+__PACKAGE__->config( 'quux' => 'chunkybacon' );
+
 sub model_foo_method { 1 }
 
+sub model_quux_method { shift->{quux} }
+
 package TestApp::Model::Foo::Bar;
 sub model_foo_bar_method_from_foo { 1 }
 
index 4261365..c15bc73 100644 (file)
@@ -1,4 +1,4 @@
-use Test::More tests => 5;
+use Test::More tests => 6;
 use strict;
 use warnings;
 use lib 't/lib';
@@ -19,3 +19,8 @@ my $model_foo_bar = $model_foo->bar;
 
 can_ok($model_foo_bar, 'model_foo_bar_method_from_foo');
 can_ok($model_foo_bar, 'model_foo_bar_method_from_foo_bar');
+
+TestApp->setup;
+
+is($model_foo->model_quux_method, 'chunkybacon', 'Model method getting $self->{quux} from config');
+