From: Dave Rolsky Date: Fri, 21 Jan 2011 20:19:48 +0000 (-0600) Subject: Small refactoring of case where there is no code for a given rest metohd X-Git-Tag: 0.89~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Action-REST.git;a=commitdiff_plain;h=65987ff6713d195c5bab155a6e07dae2b29cdc69 Small refactoring of case where there is no code for a given rest metohd --- diff --git a/lib/Catalyst/Action/REST.pm b/lib/Catalyst/Action/REST.pm index 0009f02..6382c5d 100644 --- a/lib/Catalyst/Action/REST.pm +++ b/lib/Catalyst/Action/REST.pm @@ -102,17 +102,18 @@ sub dispatch { } # Generic handling for foo_OPTIONS - if (!$code && $c->request->method eq "OPTIONS") { - $name = $rest_method; - $code = sub { $self->_return_options($self->name, @_) }; - } - - # Otherwise, not implemented. if (!$code) { - $name = $self->name . "_not_implemented"; - $code = $controller->can($name) # User method - # Generic not implemented - || sub { $self->_return_not_implemented($self->name, @_) }; + if ( $c->request->method eq "OPTIONS") { + $name = $rest_method; + $code = sub { $self->_return_options($self->name, @_) }; + } + else { + # Otherwise, not implemented. + $name = $self->name . "_not_implemented"; + $code = $controller->can($name) # User method + # Generic not implemented + || sub { $self->_return_not_implemented($self->name, @_) }; + } } # localise stuff so we can dispatch the action 'as normal, but get