X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FDispatcher.pm;h=c0daccd14e8112f722d0248642311122fe3f1070;hb=2d752b2a8829f424075d4619e9d4edd852adbf46;hp=22e648ae81f5ea629d5b11595cb1a08f33f1a97d;hpb=9c0533794810864b73b1ca476b75f22d32ac3a10;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 22e648a..c0daccd 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -2,7 +2,7 @@ package Catalyst::Dispatcher; use strict; use base 'Class::Data::Inheritable'; -use Memoize; +use Catalyst::Utils; use Text::ASCIITable; use Tree::Simple; use Tree::Simple::Visitor::FindByPath; @@ -17,8 +17,6 @@ __PACKAGE__->actions( # We use a tree __PACKAGE__->tree( Tree::Simple->new( 0, Tree::Simple->ROOT ) ); -memoize('_class2prefix'); - =head1 NAME Catalyst::Dispatcher - The Catalyst Dispatcher @@ -48,7 +46,8 @@ sub dispatch { unless ($namespace) { if ( my $result = $c->get_action($action) ) { - $namespace = _class2prefix( $result->[0]->[0]->[0] ); + $namespace = + Catalyst::Utils::class2prefix( $result->[0]->[0]->[0] ); } } @@ -130,7 +129,7 @@ sub forward { $command =~ s/^\///; } - else { $namespace = _class2prefix($caller) || '/' } + else { $namespace = Catalyst::Utils::class2prefix($caller) || '/' } my $results = $c->get_action( $command, $namespace ); @@ -236,13 +235,7 @@ sub get_action { my $name = $c->actions->{compiled}->[$i]->[0]; my $regex = $c->actions->{compiled}->[$i]->[1]; - if ( $action =~ $regex ) { - my @snippets; - for my $i ( 1 .. 9 ) { - no strict 'refs'; - last unless ${$i}; - push @snippets, ${$i}; - } + if ( my @snippets = ( $action =~ $regex ) ) { return [ [ $c->actions->{regex}->{$name}, $name, \@snippets ] ]; } @@ -260,7 +253,7 @@ Set an action in a given namespace. sub set_action { my ( $c, $method, $code, $namespace, $attrs ) = @_; - my $prefix = _class2prefix($namespace) || ''; + my $prefix = Catalyst::Utils::class2prefix($namespace) || ''; my %flags; for my $attr ( @{$attrs} ) { @@ -442,23 +435,6 @@ sub setup_actions { if ( @{ $regexes->{tbl_rows} } && $self->debug ); } -sub _prefix { - my ( $class, $name ) = @_; - my $prefix = _class2prefix($class); - $name = "$prefix/$name" if $prefix; - return $name; -} - -sub _class2prefix { - my $class = shift || ''; - my $prefix; - if ( $class =~ /^.*::([MVC]|Model|View|Controller)?::(.*)$/ ) { - $prefix = lc $2; - $prefix =~ s/\:\:/\//g; - } - return $prefix; -} - =back =head1 AUTHOR