File: Cleanup.pm

package info (click to toggle)
libplack-middleware-session-perl 0.36-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 276 kB
  • sloc: perl: 1,322; makefile: 2
file content (57 lines) | stat: -rw-r--r-- 911 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package Plack::Session::Cleanup;
use strict;
use warnings;

our $VERSION   = '0.36';
our $AUTHORITY = 'cpan:STEVAN';

sub new {
    my $class = shift;
    my $subref = shift;
    my $self = bless $subref, $class;
    return $self;
}

sub DESTROY {
    my $self = shift;
    $self->();
}

1;

__END__

=pod

=head1 NAME

Plack::Session::Cleanup - Run code when the environment is destroyed

=head1 SYNOPSIS

  $env->{'run_at_cleanup'} = Plack::Session::Cleanup->new(
      sub {
          # ...
      }
  );


=head1 DESCRIPTION

This provides a way for L<Plack::Middleware::Session> to run code when
the environment is cleaned up.

=head1 METHODS

=over 4

=item B<new ( $coderef )>

Executes the given code reference when the object is C<DESTROY>'d.  Care
should be taken that the given code reference does not close over
C<$env>, creating a cycle and preventing the C<$env> from being
destroyed.

=back

=cut