| 1 | =head1 NAME | ||||||||||
| 2 | |||||||||||
| 3 | OpenFrame::WebApp::Session::Factory - a factory for various types of session | ||||||||||
| 4 | wrappers. | ||||||||||
| 5 | |||||||||||
| 6 | =head1 SYNOPSIS | ||||||||||
| 7 | |||||||||||
| 8 | use OpenFrame::WebApp::Session::Factory; | ||||||||||
| 9 | |||||||||||
| 10 | my $sfactory = new OpenFrame::WebApp::Session::Factory() | ||||||||||
| 11 | ->type( 'file_cache' ) | ||||||||||
| 12 | ->expiry( $period ); # optional | ||||||||||
| 13 | |||||||||||
| 14 | my $session = $sfactory->new_session( @args ); | ||||||||||
| 15 | my $session = $sfactory->fetch_session( $id ); | ||||||||||
| 16 | |||||||||||
| 17 | =cut | ||||||||||
| 18 | |||||||||||
| 19 | package OpenFrame::WebApp::Session::Factory; | ||||||||||
| 20 | |||||||||||
| 21 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 4 | ▶ | use warnings::register; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | |||||||||||
| 24 | 4 | ▶ | use OpenFrame::WebApp::Session; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | 4 | our $VERSION = (split(/ /, '$Revision: 1.4 $'))[1]; | |||||||||
| 27 | |||||||||||
| 28 | 4 | ▶ | use base qw ( OpenFrame::WebApp::Factory ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | |||||||||||
| 30 | 4 | ▶ | sub expiry { | ||||||||
|
Subroutine
expiry: called CC=2 SCAR=8.4
Pod
documented
| |||||||||||
| 31 | 4 | my $self = shift; | |||||||||
| 32 | 4 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 0 | $self->{session_expiry} = shift; | |||||||||
| 34 | 0 | return $self; | |||||||||
| 35 | } else { | ||||||||||
| 36 | 4 | return $self->{session_expiry}; | |||||||||
| 37 | } | ||||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 10 | ▶ | sub get_types_class { | ||||||||
|
Subroutine
get_types_class: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 41 | 10 | my $self = shift; | |||||||||
| 42 | 10 | return OpenFrame::WebApp::Session->types->{$self->type}; | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 4 | ▶ | sub new_session { | ||||||||
|
Subroutine
new_session: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 46 | 4 | my $self = shift; | |||||||||
| 47 | 4 | my $sess = $self->new_object(); | |||||||||
| 48 | 4 | ▶ | $sess->expiry( $self->expiry ) if ($self->expiry); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 4 | return $sess; | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 2 | ▶ | sub fetch_session { | ||||||||
|
Subroutine
fetch_session: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 53 | 2 | my $self = shift; | |||||||||
| 54 | 2 | my $id = shift; | |||||||||
| 55 | 2 | $self->load_types_class->fetch( $id ); | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | |||||||||||
| 59 | 4 | 1; | |||||||||
| 60 | |||||||||||
| 61 | __END__ | ||||||||||