Change Catalsyt _parse_attrs so that when sub attr handlers:
[catagits/Catalyst-Runtime.git] / t / lib / TestApp / Controller / Attributes.pm
1 use strict;
2 use warnings;
3
4 package My::AttributesBaseClass;
5 use base qw( Catalyst::Controller );
6
7 sub fetch : Chained('/') PathPrefix CaptureArgs(0) { }
8
9 sub left_alone :Chained('fetch') PathPart Args(0) { }
10
11 sub view : PathPart Chained('fetch') Args(0) { }
12
13 sub foo { } # no attributes
14
15 package TestApp::Controller::Attributes;
16 use base qw(My::AttributesBaseClass);
17
18 sub _parse_MakeMeVisible_attr {
19     my ($self, $c, $name, $value) = @_;
20     if (!$value){
21         return Chained => 'fetch', PathPart => 'all_attrs', Args => 0;
22     }
23     elsif ($value eq 'some'){
24         return Chained => 'fetch', Args => 0;
25     }
26     elsif ($value eq 'one'){
27         return PathPart => 'one_attr';
28     }
29 }
30
31 sub view { }    # override attributes to "hide" url
32
33 sub foo : Local { }
34
35 sub all_attrs_action :MakeMeVisible { }
36
37 sub some_attrs_action :MakeMeVisible('some') PathPart('some_attrs') { }
38
39 sub one_attr_action :MakeMeVisible('one') Chained('fetch') Args(0) { }
40
41 1;