diff options
author | Jesse Luehrs <doy@tozt.net> | 2011-02-18 12:25:57 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2011-02-18 12:25:57 -0600 |
commit | 18f07a26819d72517556849fc59c9860a90d3c9c (patch) | |
tree | 6fca0dbab71a937aa04705c6ff663999becbaf46 /lib | |
parent | f4b3b90c3ccef7deb127c3ea1fc46984d64db605 (diff) | |
download | narwhal-18f07a26819d72517556849fc59c9860a90d3c9c.tar.gz narwhal-18f07a26819d72517556849fc59c9860a90d3c9c.zip |
use new route builder api
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Narwhal.pm | 3 | ||||
-rw-r--r-- | lib/Narwhal/RouteBuilder/HTTPMethod.pm | 25 |
2 files changed, 11 insertions, 17 deletions
diff --git a/lib/Narwhal.pm b/lib/Narwhal.pm index 0a7a24e..612c2b9 100644 --- a/lib/Narwhal.pm +++ b/lib/Narwhal.pm @@ -1,6 +1,5 @@ package Narwhal; use OX; -use Narwhal::RouteBuilder::HTTPMethod; with 'OX::Role::WithAppRoot'; @@ -41,7 +40,7 @@ component Kioku => 'Narwhal::Component::Model', ( extra_args => depends_on('/Config/kioku_extra_args'), ); -router as { +router ['Narwhal::RouteBuilder::HTTPMethod'], as { route '/' => 'redirect.permanent', ( to => '/page/main', ); diff --git a/lib/Narwhal/RouteBuilder/HTTPMethod.pm b/lib/Narwhal/RouteBuilder/HTTPMethod.pm index 9631616..33fe893 100644 --- a/lib/Narwhal/RouteBuilder/HTTPMethod.pm +++ b/lib/Narwhal/RouteBuilder/HTTPMethod.pm @@ -3,21 +3,6 @@ use Moose; with 'OX::RouteBuilder'; -sub import { - my $meta = Class::MOP::class_of(caller); - $meta->add_route_builder( - class => __PACKAGE__, - route_spec => sub { - my $spec = shift; - return if ref($spec); - return unless $spec =~ /^http-method:(\w+)$/; - return { - action => $1, - }; - }, - ); -} - sub compile_routes { my $self = shift; @@ -59,6 +44,16 @@ sub compile_routes { ]; } +sub parse_action_spec { + my $self = shift; + my ($action_spec) = @_; + return if ref($action_spec); + return unless $action_spec =~ /^http-method:(\w+)$/; + return { + action => $1, + }; +} + __PACKAGE__->meta->make_immutable; no Moose; |