[Catalyst-commits] r6250 - in trunk/CatalystX-Imports:
lib/CatalystX lib/CatalystX/Imports/Context t
t/lib/TestApp/Controller t/lib/TestApp/Model
phaylon at dev.catalyst.perl.org
phaylon at dev.catalyst.perl.org
Sat Mar 31 21:01:56 GMT 2007
Author: phaylon
Date: 2007-03-31 21:01:54 +0100 (Sat, 31 Mar 2007)
New Revision: 6250
Added:
trunk/CatalystX-Imports/t/lib/TestApp/Model/TestAC.pm
Modified:
trunk/CatalystX-Imports/lib/CatalystX/Imports.pm
trunk/CatalystX-Imports/lib/CatalystX/Imports/Context/Default.pm
trunk/CatalystX-Imports/t/10-context-basic.t
trunk/CatalystX-Imports/t/lib/TestApp/Controller/Basic.pm
Log:
fixed component argument issue (phaylon)
Modified: trunk/CatalystX-Imports/lib/CatalystX/Imports/Context/Default.pm
===================================================================
--- trunk/CatalystX-Imports/lib/CatalystX/Imports/Context/Default.pm 2007-03-31 16:03:13 UTC (rev 6249)
+++ trunk/CatalystX-Imports/lib/CatalystX/Imports/Context/Default.pm 2007-03-31 20:01:54 UTC (rev 6250)
@@ -141,8 +141,10 @@
__PACKAGE__->register_export(
name => $type,
code => sub {
- my ($library, $self, $c, $a_args, $name) = @_;
- return $library->resolve_component($self, $c, $type, $name);
+ my ($library, $self, $c, $a_args, $name, @args)
+ = @_[ @Pos{qw( LIB SELF CTX A_ARGS )}, $Pos{ARGS} .. $#_ ];
+# my ($library, $self, $c, $a_args, $name) = @_;
+ return $library->resolve_component($self, $c, $type, $name, \@args);
},
tags => [qw( intro mvc )],
);
Modified: trunk/CatalystX-Imports/lib/CatalystX/Imports.pm
===================================================================
--- trunk/CatalystX-Imports/lib/CatalystX/Imports.pm 2007-03-31 16:03:13 UTC (rev 6249)
+++ trunk/CatalystX-Imports/lib/CatalystX/Imports.pm 2007-03-31 20:01:54 UTC (rev 6250)
@@ -301,7 +301,7 @@
=cut
sub resolve_component {
- my ($class, $controller, $c, $type, $name) = @_;
+ my ($class, $controller, $c, $type, $name, $args) = @_;
# just use the name if nothing is configured at all
my $config = $controller->config->{component_prefix};
@@ -322,7 +322,7 @@
# try to find a component under that prefix and return it if found
for my $prefix (@$config) {
my $comp_name = join('::', grep { $_ } $prefix, $name);
- my $comp = $c->$type($comp_name);
+ my $comp = $c->$type($comp_name, @{ $args || [] });
return $comp if defined($comp);
}
Modified: trunk/CatalystX-Imports/t/10-context-basic.t
===================================================================
--- trunk/CatalystX-Imports/t/10-context-basic.t 2007-03-31 16:03:13 UTC (rev 6249)
+++ trunk/CatalystX-Imports/t/10-context-basic.t 2007-03-31 20:01:54 UTC (rev 6250)
@@ -28,6 +28,7 @@
['uri_for', undef, 'http://localhost/3/4/5/test_captures/foo?x=7'],
['model', undef, 23],
['model w/ prefix', '/test_model_w_prefix', 'Prefix_Foo'],
+ ['model w/ AC', '/test_model_withac/1/2/3', '1, 2, 3'],
['response', undef, 1],
['request', undef, 1],
['has_param #t', '/test_has_param?foo=12', 1],
Modified: trunk/CatalystX-Imports/t/lib/TestApp/Controller/Basic.pm
===================================================================
--- trunk/CatalystX-Imports/t/lib/TestApp/Controller/Basic.pm 2007-03-31 16:03:13 UTC (rev 6249)
+++ trunk/CatalystX-Imports/t/lib/TestApp/Controller/Basic.pm 2007-03-31 20:01:54 UTC (rev 6250)
@@ -62,6 +62,11 @@
$c->res->body( model('TestModel')->foo );
}
+sub test_model_withac: Chained('base') {
+ my ($self, $c, @args) = @_;
+ $c->res->body( model('TestAC', @args)->join );
+}
+
sub test_response: Chained('base') {
my ($self, $c) = @_;
$c->res->body( response->isa('Catalyst::Response') ? 1 :0 );
Added: trunk/CatalystX-Imports/t/lib/TestApp/Model/TestAC.pm
===================================================================
--- trunk/CatalystX-Imports/t/lib/TestApp/Model/TestAC.pm (rev 0)
+++ trunk/CatalystX-Imports/t/lib/TestApp/Model/TestAC.pm 2007-03-31 20:01:54 UTC (rev 6250)
@@ -0,0 +1,21 @@
+package TestApp::Model::TestAC;
+use warnings;
+use strict;
+
+sub new {
+ my $class = shift;
+ return bless { @_ }, $class;
+}
+
+sub ACCEPT_CONTEXT {
+ my ($class, $c, @args) = @_;
+ $class->new( list => \@args );
+}
+
+sub join {
+ my ($self, $sep) = @_;
+ $sep ||= ', ',
+ return join $sep, @{ $self->{list} || [] };
+}
+
+1;
More information about the Catalyst-commits
mailing list