X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FDispatchType.pm;h=fb4d0affed12e3676da9191d1cd11a1a02a32df1;hp=f8df3911e15c8a885a721a7f0958118d21823c5b;hb=26dc649ad1a74622697f25fcbf29e806e75fcd2f;hpb=2633d7dc3bb9c0cf7bf3e7cf936d6411fe3ba5aa diff --git a/lib/Catalyst/DispatchType.pm b/lib/Catalyst/DispatchType.pm index f8df391..fb4d0af 100644 --- a/lib/Catalyst/DispatchType.pm +++ b/lib/Catalyst/DispatchType.pm @@ -1,7 +1,8 @@ package Catalyst::DispatchType; -use strict; -use base 'Class::Accessor::Fast'; +use Moose; +with 'MooseX::Emulate::Class::Accessor::Fast'; +no Moose; =head1 NAME @@ -13,28 +14,68 @@ See L. =head1 DESCRIPTION +This is an abstract base class for Dispatch Types. + +From a code perspective, dispatch types are used to find which actions +to call for a given request URL. Website authors will typically work +with them via subroutine names attributes; a description of dispatch +at the attribute/URL level is given in L. + =head1 METHODS -=over 4 +=head2 $self->list($c) + +abstract method, to be implemented by dispatchtypes. Called to display +info in debug log. + +=cut + +sub list { } + +=head2 $self->match( $c, $path ) -=item $self->match( $c, $path ) +abstract method, to be implemented by dispatchtypes. Returns true if the +dispatch type matches the given path =cut sub match { die "Abstract method!" } -=item $self->register( $c, $action ) +=head2 $self->register( $c, $action ) + +abstract method, to be implemented by dispatchtypes. Takes a +context object and a L object. + +Should return true if it registers something, or false otherwise. =cut -sub register { return } +sub register { } -=back +=head2 $self->uri_for_action( $action, \@captures ) -=head1 AUTHOR +abstract method, to be implemented by dispatchtypes. Takes a +L object and an arrayref of captures, and should +return either a URI part which if placed in $c->req->path would cause +$self->match to match this action and set $c->req->captures to the supplied +arrayref, or undef if unable to do so. -Matt S Trout -Sebastian Riedel, C +=cut + +sub uri_for_action { } + +=head2 $self->expand_action + +Default fallback, returns nothing. See L for more info +about expand_action. + +=cut + +sub expand_action { } + +=head1 AUTHORS + +Catalyst Contributors, see Catalyst.pm =head1 COPYRIGHT @@ -43,4 +84,6 @@ the same terms as Perl itself. =cut +__PACKAGE__->meta->make_immutable; + 1;