package Catalyst::DispatchType::Regex;
-use strict;
-use base qw/Catalyst::DispatchType::Path/;
+use Moose;
+extends 'Catalyst::DispatchType::Path';
+
use Text::SimpleTable;
use Text::Balanced ();
+has _compiled => (
+ is => 'rw',
+ isa => 'ArrayRef',
+ required => 1,
+ default => sub{ [] },
+ );
+
+no Moose;
+
=head1 NAME
Catalyst::DispatchType::Regex - Regex DispatchType
sub list {
my ( $self, $c ) = @_;
my $re = Text::SimpleTable->new( [ 35, 'Regex' ], [ 36, 'Private' ] );
- for my $regex ( @{ $self->{compiled} } ) {
+ for my $regex ( @{ $self->_compiled } ) {
my $action = $regex->{action};
$re->row( $regex->{path}, "/$action" );
}
$c->log->debug( "Loaded Regex actions:\n" . $re->draw . "\n" )
- if ( @{ $self->{compiled} } );
+ if ( @{ $self->_compiled } );
}
=head2 $self->match( $c, $path )
# Check path against plain text first
- foreach my $compiled ( @{ $self->{compiled} || [] } ) {
+ foreach my $compiled ( @{ $self->_compiled } ) {
if ( my @captures = ( $path =~ $compiled->{re} ) ) {
next unless $compiled->{action}->match($c);
$c->req->action( $compiled->{path} );
=head2 $self->register_regex($c, $re, $action)
-Register an individual regex on the action. Usually called from the
+Register an individual regex on the action. Usually called from the
register method.
=cut
sub register_regex {
my ( $self, $c, $re, $action ) = @_;
push(
- @{ $self->{compiled} }, # and compiled regex for us
+ @{ $self->_compiled }, # and compiled regex for us
{
re => qr#$re#,
action => $action,
return undef;
}
-=head1 AUTHOR
+=head1 AUTHORS
-Matt S Trout
-Sebastian Riedel, C<sri@cpan.org>
+Catalyst Contributors, see Catalyst.pm
=head1 COPYRIGHT
=cut
+__PACKAGE__->meta->make_immutable;
+
1;