CatalystX/GlobalContext.pm

filter: Statementstmt 100% 21 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 100% 28 / 28 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Catalyst/Controller/CGIBin.pm ↑ Summary
1 package CatalystX::GlobalContext;
2 3 our $AUTHORITY = 'cpan:RKITOVER';
3 3 $CatalystX::GlobalContext::VERSION = '0.039';
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶use Scalar::Util 'weaken';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 ▶use vars '$c';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 our @EXPORT_OK = '$c';
12  
13 =head1 NAME
14  
15 CatalystX::GlobalContext - Export Catalyst Context
16  
17 =head1 SYNOPSIS
18  
19 package MyApp::Controller::Root;
20  
21 use CatalystX::GlobalContext ();
22  
23 sub auto : Private {
24 my ($self, $c) = @_;
25 CatalystX::GlobalContext->set_context($c);
26 1;
27 }
28  
29 package Some::Other::Module;
30  
31 use CatalystX::GlobalContext '$c';
32  
33 ...
34 do stuff with $c
35 ...
36  
37 =head1 DESCRIPTION
38  
39 This module, in combination with L<Catalyst::Controller::WrapCGI> or
40 L<Catalyst::Controller::CGIBin> is for helping you run legacy mod_perl code in
41 L<Catalyst>.
42  
43 You save a copy of $c somewhere at the beginning of the request cycle, and it is
44 then accessible through an export where you need it.
45  
46 You can then rip out C<Apache::> type things, and replace them with things based on
47 C<$c>.
48  
49 =head1 CLASS METHODS
50  
51 =head2 CatalystX::GlobalContext->set_context($c)
52  
53 Saves a weakened reference to the Catalyst context,
54 which is accessible from other modules as an export.
55  
56 =cut
57  
58 1 ▶sub set_context {
Subroutine set_context: called CC=1 SCAR=0.0
Pod documented
59 1 $c = $_[1];
60 1 weaken $c;
61 }
62  
63 =head1 SEE ALSO
64  
65 L<Catalyst::Controller::CGIBin>, L<Catalyst::Controller::WrapCGI>,
66 L<Catalyst>
67  
68 =head1 BUGS
69  
70 Please report any bugs or feature requests to C<bug-catalyst-controller-wrapcgi
71 at rt.cpan.org>, or through the web interface at
72 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Controller-WrapCGI>.
73 I will be notified, and then you'll automatically be notified of progress on
74 your bug as I make changes.
75  
76 =head1 AUTHOR
77  
78 Rafael Kitover <rkitover@gmail.com>
79  
80 =head1 COPYRIGHT & LICENSE
81  
82 Copyright (c) 2008-2015 Rafael Kitover <rkitover@gmail.com> and
83 L<Catalyst::Controller::WrapCGI/CONTRIBUTORS>.
84  
85 This program is free software; you can redistribute it and/or modify it
86 under the same terms as Perl itself.
87  
88 =cut
89  
90 3 __PACKAGE__; # End of CatalystX::GlobalContext
91  
92 # vim: expandtab shiftwidth=4 ts=4 tw=80:
« Catalyst/Controller/CGIBin.pm ↑ Summary