File Coverage

blib/lib/Catalyst/Plugin/SpecialAction/Trail.pm
Criterion Covered Total %
statement 4 6 66.6
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 6 8 75.0


line stmt bran cond sub pod time code
1             package Catalyst::Plugin::SpecialAction::Trail;
2              
3 1     1   88163 use 5.008;
  1         5  
  1         36  
4              
5 1     1   499 use Moose::Role;
  0            
  0            
6             use namespace::autoclean;
7              
8             use Moose::Util qw/ ensure_all_roles /;
9              
10             =head1 NAME
11              
12             Catalyst::Plugin::SpecialAction::Trail - Support for the 'trail' special action
13              
14             =head1 VERSION
15              
16             Version 0.01
17              
18             =cut
19              
20             our $VERSION = '0.01';
21              
22              
23             =head1 SYNOPSIS
24              
25             # enabling the 'trail' special action in a single controller:
26              
27             package MyApp::Controller::Foo;
28              
29             use Moose;
30             use namespace::autoclean;
31              
32             extends 'Catalyst::Controller';
33              
34             with 'Catalyst::TraitFor::Controller::SpecialAction::Trail';
35              
36             sub trail : Private {
37             my ($self, $c, @args) = (shift, shift, @_);
38              
39             ...
40             }
41              
42             # globally enabling the 'trail' special action:
43              
44             package MyApp;
45              
46             use Moose;
47             use namespace::autoclean;
48              
49             extends 'Catalyst';
50              
51             __PACKAGE__->setup(qw/ SpecialAction::Trail /);
52              
53             # now you can use 'trail' in any controller in your app
54              
55             =head1 DISCLAIMER
56              
57             This is ALPHA SOFTWARE. Use at your own risk. Features may change.
58              
59             =head1 DESCRIPTION
60              
61             This module introduces a new special action C<trail> that unites the features
62             of C<end> and C<auto> special actions (see L<Catalyst::Manual::Intro/"Built-in
63             special actions">):
64              
65             =over
66              
67             =item *
68              
69             Like C<end>, the C<trail> actions will be run at the end of the request, after
70             all URL-matching actions are called; but they are called before any C<end> is
71             run.
72              
73             =item *
74              
75             Like C<auto>, multiple C<trail> actions will be run in turn, starting with the
76             application class and going through to the most specific controller class, and
77             the processing chain stops if any of them returns false (any remaining C<trail>
78             actions are skipped and the control goes to C<end> if there's any).
79              
80             =back
81              
82             =head1 METHODS
83              
84             =cut
85              
86             =head2 setup_component
87              
88             Overridden (with an 'around' method modifier) from L<Catalyst/setup_component>.
89             Applies the L<Catalyst::TraitFor::Controller::SpecialAction::Trail> role to
90             the C<Catalyst::Controller> instance.
91              
92             =cut
93              
94             around setup_component => sub {
95             my ($orig, $class) = (shift, shift, @_);
96              
97             my $component = $class->$orig(@_);
98              
99             if ($component->isa('Catalyst::Controller')) {
100             ensure_all_roles($component,
101             'Catalyst::TraitFor::Controller::SpecialAction::Trail');
102             }
103              
104             return $component;
105             };
106              
107              
108             =head1 SEE ALSO
109              
110             L<Catalyst>, L<Catalyst::Manual::Intro>.
111              
112             =head1 AUTHOR
113              
114             Norbert Buchmuller, C<< <norbi at nix.hu> >>
115              
116             =head1 BUGS
117              
118             Please report any bugs or feature requests to
119             C<bug-catalyst-plugin-specialaction-trail at rt.cpan.org>, or through the web
120             interface at
121             L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Plugin-SpecialAction-Trail>.
122             I will be notified, and then you'll automatically be notified of progress on
123             your bug as I make changes.
124              
125             =head1 SUPPORT
126              
127             You can find documentation for this module with the perldoc command.
128              
129             perldoc Catalyst::Plugin::SpecialAction::Trail
130              
131             You can also look for information at:
132              
133             =over 4
134              
135             =item * RT: CPAN's request tracker
136              
137             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-Plugin-SpecialAction-Trail>
138              
139             =item * AnnoCPAN: Annotated CPAN documentation
140              
141             L<http://annocpan.org/dist/Catalyst-Plugin-SpecialAction-Trail>
142              
143             =item * CPAN Ratings
144              
145             L<http://cpanratings.perl.org/d/Catalyst-Plugin-SpecialAction-Trail>
146              
147             =item * Search CPAN
148              
149             L<http://search.cpan.org/dist/Catalyst-Plugin-SpecialAction-Trail/>
150              
151             =back
152              
153             =head1 ACKNOWLEDGEMENTS
154              
155             =head1 COPYRIGHT & LICENSE
156              
157             Copyright 2010 Norbert Buchmuller, all rights reserved.
158              
159             This program is free software; you can redistribute it and/or modify it
160             under the same terms as Perl itself.
161              
162             =cut
163              
164             1; # End of Catalyst::Plugin::SpecialAction::Trail