X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalystX%2FRoutes.pm;h=0e4acc38a93340a76f846411b9a9672add1f80c9;hb=bd470bcc04e551734d33e136d4824cce0519b1b5;hp=ccd2fa7c413b957929d5f4b793c677b4fde00a69;hpb=7bdb05c2732d4d130a42713e8bd6507d7fadb44c;p=catagits%2FCatalystX-Routes.git diff --git a/lib/CatalystX/Routes.pm b/lib/CatalystX/Routes.pm index ccd2fa7..0e4acc3 100644 --- a/lib/CatalystX/Routes.pm +++ b/lib/CatalystX/Routes.pm @@ -3,8 +3,6 @@ package CatalystX::Routes; use strict; use warnings; -use CatalystX::Routes::Role::Class; -use CatalystX::Routes::Role::Controller; use Moose::Util qw( apply_all_roles ); use Params::Util qw( _CODELIKE _REGEX _STRING ); use Scalar::Util qw( blessed ); @@ -12,11 +10,8 @@ use Scalar::Util qw( blessed ); use Moose::Exporter; Moose::Exporter->setup_import_methods( - with_meta => [qw( get get_html post put del chain_point )], - as_is => [qw( chained args capture_args path_part action_class_name )], - class_metaroles => { - class => ['CatalystX::Routes::Role::Class'], - }, + with_meta => [qw( get get_html post put del chain_point )], + as_is => [qw( chained args capture_args path_part action_class_name )], ); sub get { @@ -82,7 +77,9 @@ sub _add_chain_point { my $name = $_[0]; $name =~ s{/}{|}g; - $meta->add_chain_point( $name => [ $attrs, $sub ] ); + $meta->add_method( $name => $sub ); + + $meta->name()->config()->{actions}{$name} = $attrs; } sub _process_args { @@ -129,19 +126,9 @@ sub _maybe_add_rest_route { return if $meta->has_method($name); - # This could be done by Moose::Exporter, but that would require that the - # module has already inherited from Cat::Controller when it calls "use - # CatalystX::Routes". - unless ( $meta->does_role('CatalystX::Routes::Role::Controller') ) { - apply_all_roles( - $meta->name(), - 'CatalystX::Routes::Role::Controller' - ); - } - $meta->add_method( $name => sub { } ); - $meta->add_route( $name => [ $attrs, $meta->get_method($name) ] ); + $meta->name()->config()->{actions}{$name} = $attrs; return; } @@ -189,7 +176,7 @@ sub _STRINGLIKE0 ($) { 1; -# ABSTRACT: Sugar for declaring RESTful chained action in Catalyst +# ABSTRACT: Sugar for declaring RESTful chained actions in Catalyst __END__ @@ -238,6 +225,9 @@ __END__ =head1 DESCRIPTION +B: This module is still experimental. It works well, but the APIs may +change without warning. + This module provides a sugar layer that allows controllers to declare chained RESTful actions.