File Coverage

blib/lib/Plack/Middleware/Scope/Session.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package Plack::Middleware::Scope::Session;
2 1     1   22705 use strict;
  1         2  
  1         47  
3 1     1   6 use warnings;
  1         2  
  1         33  
4 1     1   534 use Scope::Session;
  0            
  0            
5             use parent qw( Plack::Middleware );
6              
7             our $VERSION = '0.01';
8              
9             sub call {
10             my ( $self, $env ) = @_;
11             my $res;
12              
13             Scope::Session::start{
14             my $session = shift;
15             $session->set_option( 'psgi.env' => $env );
16             $res = $self->app->($env);
17             };
18             return $res;
19             }
20             1;
21             =head1 NAME
22              
23             Plack::Middleware::Scope::Session - Global Cache and Option per Request.
24              
25             =head1 VERSION
26              
27             Version 0.01
28              
29             =head1 SYNOPSIS
30              
31             Plack::Middleware::Scope::Session works like mod_perl's pnotes.
32              
33             builder {
34             enable q|Plack::Middleware::Scope::Session|
35             }
36              
37             if enable this, give your application a per-request cache
38              
39             use Scope::Session;
40              
41             sub something_in_your_application{
42             ...
43             my $env = Scope::Session->get_option('psgi.env');
44             Scope::Session->notes( 'SingletonPerRequest' , Plack::Request->new($env));
45              
46             }
47              
48             =head1 METHODS
49              
50             =head2 call
51              
52             =head1 SEE ALSO
53              
54             L,L
55              
56             =head1 AUTHOR
57              
58             Daichi Hiroki, C<< gmail.com> >>
59              
60             =head1 LICENSE AND COPYRIGHT
61              
62             Copyright 2009 Daichi Hiroki.
63              
64             This program is free software; you can redistribute it and/or modify it
65             under the terms of either: the GNU General Public License as published
66             by the Free Software Foundation; or the Artistic License.
67              
68             See http://dev.perl.org/licenses/ for more information.
69              
70              
71             =cut
72