| 1 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | package Plack::Middleware::Return::MultiLevel::Utils; | ||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Scalar::Util; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Exporter 'import'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Plack::Middleware::Return::MultiLevel; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | our @EXPORT_OK = qw(return_to_level return_to_default_level); | |||||||||
| 11 | |||||||||||
| 12 | 3 | ▶ | sub return_to_level { | ||||||||
|
Subroutine
return_to_level: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 13 | 3 | my ($proto, $level_name, @returning) = @_; | |||||||||
| 14 | 3 | ▶ | my $env = Scalar::Util::blessed($proto) ? $proto->env : $proto; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | 3 | return Plack::Middleware::Return::MultiLevel::_return_level( | |||||||||
| 16 | $env, $level_name, @returning); | ||||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 1 | ▶ | sub return_to_default_level { | ||||||||
|
Subroutine
return_to_default_level: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 20 | 1 | return return_to_level(shift, Plack::Middleware::Return::MultiLevel::DEFAULT_LEVEL_NAME, @_); | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | |||||||||||
| 24 | =head1 TITLE | ||||||||||
| 25 | |||||||||||
| 26 | Plack::Middleware::Return::MultiLevel::Utils - Ease of Use Utility subroutines | ||||||||||
| 27 | |||||||||||
| 28 | =head1 SYNOPSIS | ||||||||||
| 29 | |||||||||||
| 30 | use Plack::Middleware::Return::MultiLevel::Utils | ||||||||||
| 31 | qw/return_to_level return_to_default_level/; | ||||||||||
| 32 | |||||||||||
| 33 | return_to_default_level($env, | ||||||||||
| 34 | [200, ['Content-Type', 'text/plain'], ['default']]); | ||||||||||
| 35 | |||||||||||
| 36 | return_to_level($env, 'set_level_name', | ||||||||||
| 37 | [200, ['Content-Type', 'text/plain'], ['named level']]); | ||||||||||
| 38 | |||||||||||
| 39 | =head1 DESCRIPTION | ||||||||||
| 40 | |||||||||||
| 41 | Ideally you'd invoke your L<Return::MultiLevel> return points via one if these | ||||||||||
| 42 | importable subroutines, rather than reaching into the C<psgi_env> hash. This | ||||||||||
| 43 | gives you better encapsulation and allows the underlying code to change without | ||||||||||
| 44 | busted your use. | ||||||||||
| 45 | |||||||||||
| 46 | =head1 EXPORTS | ||||||||||
| 47 | |||||||||||
| 48 | This class defines the following exportable subroutines | ||||||||||
| 49 | |||||||||||
| 50 | =head2 return_to_default_level | ||||||||||
| 51 | |||||||||||
| 52 | return_to_default_level($env, | ||||||||||
| 53 | [200, ['Content-Type', 'text/plain'], ['default']]); | ||||||||||
| 54 | |||||||||||
| 55 | Requires C<$psgi_env> and a response, which typically is a PSGI type response, | ||||||||||
| 56 | athough you can return anything you want if there is middleware to convert it to | ||||||||||
| 57 | an acceptable PSGI style response, for example. | ||||||||||
| 58 | |||||||||||
| 59 | This can also be imported and called as a method on an object that does the C<env> | ||||||||||
| 60 | method. For example: | ||||||||||
| 61 | |||||||||||
| 62 | $catalyst_context->request->return_to_default_level(\@response); | ||||||||||
| 63 | |||||||||||
| 64 | =head2 return_to_level | ||||||||||
| 65 | |||||||||||
| 66 | return_to_level($env, 'set_level_name', | ||||||||||
| 67 | [200, ['Content-Type', 'text/plain'], ['named level']]); | ||||||||||
| 68 | |||||||||||
| 69 | Just like L</return_to_default_level> except that the second argument is the name of a | ||||||||||
| 70 | return level that you set. Also can be called as a method against an object that | ||||||||||
| 71 | does C<env>. | ||||||||||
| 72 | |||||||||||
| 73 | =head1 AUTHOR | ||||||||||
| 74 | |||||||||||
| 75 | See L<Plack::Middleware::Return::MultiLevel> | ||||||||||
| 76 | |||||||||||
| 77 | =head1 SEE ALSO | ||||||||||
| 78 | |||||||||||
| 79 | L<Plack::Middleware::Return::MultiLevel> | ||||||||||
| 80 | |||||||||||
| 81 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 82 | |||||||||||
| 83 | See L<Plack::Middleware::Return::MultiLevel> | ||||||||||
| 84 | |||||||||||
| 85 | =cut | ||||||||||
| 86 | |||||||||||
| 87 | 1 | 1; | |||||||||