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 );
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 {
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 {
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;
}
1;
-# ABSTRACT: Sugar for declaring RESTful chained action in Catalyst
+# ABSTRACT: Sugar for declaring RESTful chained actions in Catalyst
__END__
=head1 DESCRIPTION
+B<WARNING>: 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.