Commits

Fabrice Gabolde committed d47b770

_set_parent method for Routes is useless.

Comments (0)

Files changed (2)

lib/Floop/Confectionery.pm

+package Floop::Confectionery;
+
 use strict;
 use warnings;
 use 5.010;
 
 use mop;
 
-package Floop::Confectionery;
-
 use base 'Exporter';
 our @EXPORT = qw/HTTP GET POST PUT DELETE PATCH HEAD OPTIONS/;
 our @EXPORT_OK = qw/sugarcoat/;
 use Floop::Route;
 
 class Floop::Meta::MethodCandy extends mop::method {
+
     has $!http_method is rw;
     has $!pattern is rw;
     has $!parent is rw;
     has $!route;
+
     method generate_route {
         unless (defined $!route) {
+            my $parent_route;
+            if ($!parent) {
+                my $floop_class = $self->associated_meta;
+                $parent_route = $floop_class->get_method($!parent)->generate_route;
+            }
+            # TODO: have this throw usable exceptions
             my $route = Floop::Route->new(http_method => $!http_method,
                                           pattern => $!pattern,
+                                          (parent => $parent_route) x!! ($parent_route),
                                           handler => $self->body);
-            if ($!parent) {
-                my $floop_class = $self->associated_meta;
-                my $parent_route = $floop_class->get_method($!parent)->generate_route;
-                $route->_set_parent($parent_route);
-            }
             $!route = $route;
         }
         return $!route;
     }
+
 }
 
 sub sugarcoat {

lib/Floop/Route.pm

 
     }
 
-    method _set_parent($parent) {
-        croak "Cannot change parent after it has been set"
-            if defined $!parent;
-        $!parent = $parent;
-    }
-
 }
 
 __END__
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.