[Catalyst] overriding the match method for custom actions

John Napiorkowski jjn1056 at yahoo.com
Thu Feb 8 16:20:28 GMT 2007


Hi,

Does anyone know the correct way to override the match
method of an Action?  The docs give a great example
for overriding the execute method, and there are some
CPAN examples showing how to override dispatch, but I
can't seem to find one for match.  From looking at the
source code I gather that this function should return
1 if the match is successful and false otherwise.  I
have two questions:

1) When the match fails should I "return;" or do I
need to literally "return 0;".  Both seem to work, but
I haven't done too many tests.  Does anyone know?

2) It's correct to explicitly return the result of the
superclass?  Something like:

sub match
{
  my ( $self, $c ) = @_;

  ## where _check_custom_match does something and then
  ## return 1 or 0 based on the outcome.

  my $status = $self->_check_custom_match($c) &&
   $self->NEXT::match( @_ );

  return $status;
}

Does this look right to you?

BTW, does anyone know if your custom matches get run
when doing a $c->uri_for($c->action, [@Args])?  What I
mean is that $c->uri_for($c->action, ...) will return
nothing if you don't pass the expected arguments,
which tells me that the match method must get invoked,
but I'm not sure if my custom matches also get
invoked.  I think it would be great if it did. 
Anyway, I'll experiment a bit and try to figure it
out.

Thanks!
John 


 
____________________________________________________________________________________
No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/mail 



More information about the Catalyst mailing list