Small refactoring of case where there is no code for a given rest metohd
Dave Rolsky [Fri, 21 Jan 2011 20:19:48 +0000 (14:19 -0600)]
lib/Catalyst/Action/REST.pm

index 0009f02..6382c5d 100644 (file)
@@ -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