From 18f07a26819d72517556849fc59c9860a90d3c9c Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 18 Feb 2011 12:25:57 -0600 Subject: use new route builder api --- lib/Narwhal.pm | 3 +-- 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; -- cgit v1.2.3