use strict;
use warnings;
-
+
use Type::Utils -all;
use Types::Standard -types;
use Type::Library
-base,
-declare => qw( UserId Heart User ContextLike );
- extends "Types::Standard";
+ extends "Types::Standard";
class_type User, { class => "MyApp::Model::User::user" };
duck_type ContextLike, [qw/model/];
sub any_priority_link_any :Chained(link_any) PathPart('') Args(1) { $_[1]->res->body('any_priority_link_any') }
sub int_priority_link_any :Chained(link_any) PathPart('') Args(Int) { $_[1]->res->body('int_priority_link_any') }
-
+
sub link_int :Chained(chain_base) PathPart('') CaptureArgs(Int) { }
sub any_priority_link :Chained(link_int) PathPart('') Args(1) { $_[1]->res->body('any_priority_link') }
use Moose;
use MooseX::MethodAttributes;
- use namespace::autoclean;
+ use namespace::clean -except => [ 'meta' ];
use MyApp::Types qw/Int/;
use Moose::Role;
use MooseX::MethodAttributes::Role;
+ use MyApp::Types qw/Int/;
sub an_int :Local Args(Int) {
my ($self, $c, $int) = @_;
$c->res->body('an_int (withrole)');
}
+ sub an_int_ns :Local Args(MyApp::Types::Int) {
+ my ($self, $c, $int) = @_;
+ $c->res->body('an_int (withrole)');
+ }
+
+ package MyApp::BaseController;
+ $INC{'MyApp/BaseController.pm'} = __FILE__;
+
+ use Moose;
+ use MooseX::MethodAttributes;
+ use MyApp::Types qw/Int/;
+
+ extends 'Catalyst::Controller';
+
+ sub from_parent :Local Args(Int) {
+ my ($self, $c, $id) = @_;
+ $c->res->body("from_parent $id");
+ }
+
package MyApp::Controller::WithRole;
$INC{'MyApp/Controller/WithRole.pm'} = __FILE__;
use Moose;
use MooseX::MethodAttributes;
- extends 'Catalyst::Controller';
+ extends 'MyApp::BaseController';
with 'MyApp::Role';
package MyApp;
use Catalyst;
- MyApp->setup;
+ MyApp->setup('-Log=fatal');
}
use Catalyst::Test 'MyApp';
is $res->content, 'default', "request '/stringy_enum/a'";
}
-{
- my $res = request '/autoclean/an_int/1';
- is $res->content, 'an_int (autoclean)';
-}
-
-{
- my $res = request '/withrole/an_int/1';
- is $res->content, 'an_int (withrole)';
-}
-
=over
| /chain_base/*/*/*/*/*/* | /chain_base (1)
}
+{
+ my $res = request '/autoclean/an_int/1';
+ is $res->content, 'an_int (autoclean)';
+}
+
+{
+ my $res = request '/withrole/an_int_ns/S';
+ is $res->content, 'default';
+}
+
+{
+ my $res = request '/withrole/an_int_ns/111';
+ is $res->content, 'an_int (withrole)';
+}
+
+{
+ my $res = request '/withrole/an_int/1';
+ is $res->content, 'an_int (withrole)';
+}
+
+{
+ my $res = request '/withrole/from_parent/1';
+ is $res->content, 'from_parent 1';
+}
done_testing;