use Catalyst::ActionContainer;
use Catalyst::DispatchType::Default;
use Catalyst::DispatchType::Index;
+use Catalyst::Utils;
use Text::SimpleTable;
use Tree::Simple;
use Tree::Simple::Visitor::FindByPath;
-use Scalar::Util ();
# Refactoring note:
# do these belong as package vars or should we build these via a builder method?
Delegate the dispatch to the action that matched the url, or return a
message about unknown resource
-
=cut
sub dispatch {
if ( my $action = $c->action ) {
$c->forward( join( '/', '', $action->namespace, '_DISPATCH' ) );
}
-
else {
my $path = $c->req->path;
my $error = $path
# go to a string path ("/foo/bar/gorch")
# or action object
- if (Scalar::Util::blessed($command) && $command->isa('Catalyst::Action')) {
+ if (blessed($command) && $command->isa('Catalyst::Action')) {
$action = $command;
}
else {
no warnings 'recursion';
- my $orig_args = $c->request->arguments();
- $c->request->arguments($args);
+ local $c->request->{arguments} = $args;
$action->dispatch( $c );
- $c->request->arguments($orig_args);
return $c->state;
}
return undef;
}
-=head2 expand_action
+=head2 expand_action
expand an action into a full representation of the dispatch.
mostly useful for chained, other actions will just return a
=head2 $self->setup_actions( $class, $context )
+Loads all of the preload dispatch types, registers their actions and then
+loads all of the postload dispatch types, and iterates over the tree of
+actions, displaying the debug information if appropriate.
=cut
sub setup_actions {
my ( $self, $c ) = @_;
-
my @classes =
$self->_load_dispatch_types( @{ $self->preload_dispatch_types } );
@{ $self->_registered_dispatch_types }{@classes} = (1) x @classes;
return unless $c->debug;
+ my $column_width = Catalyst::Utils::term_width() - 20 - 36 - 12;
my $privates = Text::SimpleTable->new(
- [ 20, 'Private' ],
- [ 36, 'Class' ],
- [ 12, 'Method' ]
+ [ 20, 'Private' ], [ 36, 'Class' ], [ $column_width, 'Method' ]
);
my $has_private = 0;
my %package_hash; # Only warn once per method, per package. These are infrequent enough that
# I haven't provided a way to disable them, patches welcome.
$meta->add_before_method_modifier($public_method_name, sub {
- my $class = Scalar::Util::blessed(shift);
+ my $class = blessed(shift);
$package_hash{$class}++ || do {
warn("Class $class is calling the deprecated method Catalyst::Dispatcher::$public_method_name,\n"
. "this will be removed in Catalyst 5.9X");