Don't try to load roles which no longer exist
Dave Rolsky [Sat, 5 Feb 2011 20:53:27 +0000 (14:53 -0600)]
lib/CatalystX/Routes.pm

index 6e019c9..0e4acc3 100644 (file)
@@ -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;
 }