[Catalyst-commits] r9546 - in
Catalyst-Runtime/5.80/branches/add_captures_to_visit: . lib/Catalyst
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Sat Mar 21 20:39:53 GMT 2009
Author: t0m
Date: 2009-03-21 20:39:52 +0000 (Sat, 21 Mar 2009)
New Revision: 9546
Modified:
Catalyst-Runtime/5.80/branches/add_captures_to_visit/Changes
Catalyst-Runtime/5.80/branches/add_captures_to_visit/lib/Catalyst/Dispatcher.pm
Log:
Cleanup, changelog
Modified: Catalyst-Runtime/5.80/branches/add_captures_to_visit/Changes
===================================================================
--- Catalyst-Runtime/5.80/branches/add_captures_to_visit/Changes 2009-03-21 18:11:04 UTC (rev 9545)
+++ Catalyst-Runtime/5.80/branches/add_captures_to_visit/Changes 2009-03-21 20:39:52 UTC (rev 9546)
@@ -1,5 +1,12 @@
# This file documents the revision history for Perl extension Catalyst.
+ - Change the $c->visit and $c->go methods to optionally take
+ CaptureArgs, making them useful to call ActionChains with (t0m)
+ - Tests for this (radek)
+ - Fix _invoke_as_component method to find the proper action instance
+ for dispatchable actions so that ->visit or ->going to ActionChains
+ with qw/Class::Name method_name/ works correctly (t0m)
+ - Tests for this (radek)
- Added Catalyst::Test::ctx_request to be able to inspect
the context object after a request is made (Jos Boumans)
- debug() POD rewrite (jhannah)
Modified: Catalyst-Runtime/5.80/branches/add_captures_to_visit/lib/Catalyst/Dispatcher.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/add_captures_to_visit/lib/Catalyst/Dispatcher.pm 2009-03-21 18:11:04 UTC (rev 9545)
+++ Catalyst-Runtime/5.80/branches/add_captures_to_visit/lib/Catalyst/Dispatcher.pm 2009-03-21 20:39:52 UTC (rev 9546)
@@ -307,43 +307,44 @@
}
}
-sub _find_component_class {
+sub _find_component {
my ( $self, $c, $component ) = @_;
- return ref($component)
- || ref( $c->component($component) )
- || $c->component($component);
+ # fugly, why doesn't ->component('MyApp') work?
+ return $c if ($component eq blessed($c));
+
+ return blessed($component)
+ ? $component
+ : $c->component($component);
}
sub _invoke_as_component {
- my ( $self, $c, $component, $method ) = @_;
+ my ( $self, $c, $component_or_class, $method ) = @_;
- #FIXME - Is this resolving needed/should it just return the instance
- # directly
- my $class = $self->_find_component_class( $c, $component ) || return 0;
+ my $component = $self->_find_component($c, $component_or_class);
+ my $component_class = blessed $component || return 0;
- my $component_instance = $c->component($class);
- if (my $code = $component_instance->can('action_for')) {
- my $possible_action = $component_instance->$code($method);
+ if (my $code = $component_class->can('action_for')) {
+ my $possible_action = $component->$code($method);
return $possible_action if $possible_action;
}
- if ( my $code = $class->can($method) ) {
+ if ( my $code = $component_class->can($method) ) {
return $self->_method_action_class->new(
{
name => $method,
code => $code,
- reverse => "$class->$method",
- class => $class,
+ reverse => "$component_class->$method",
+ class => $component_class,
namespace => Catalyst::Utils::class2prefix(
- $class, $c->config->{case_sensitive}
+ $component_class, $c->config->{case_sensitive}
),
}
);
}
else {
my $error =
- qq/Couldn't forward to "$class". Does not implement "$method"/;
+ qq/Couldn't forward to "$component_class". Does not implement "$method"/;
$c->error($error);
$c->log->debug($error)
if $c->debug;
More information about the Catalyst-commits
mailing list