広木 大地 > Scope-Session-0.02 > Scope::Session

Download:
Scope-Session-0.02.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  0
View/Report Bugs
Source  

NAME ^

Scope::Session - a scope based object note and option store

VERSION ^

Version 0.02

SYNOPSIS ^

Scope::Session is a Scope lifetime object store , which can use as a replacement of Apache::Request::Util::pnotes.

    use Scope::Session;

    Scope::Session::start {
        my $session = shift;
        $session->notes( $key => $value );
        # your great code.
        #
    };

METHODS ^

start

get a block and start session

get_instance

get_instance returns instance of Scope::Session. It is unique in the block called at Scope::Session::start.

    use Scope::Session;
    
    Scope::Session::start {
        my $session  = Scope::Session->get_instance;
    };

set_option

to set a session unique option value

    Scope::Session->set_option( KEY => VALUE )

get_option

to get a session unique option value

    Scope::Session->get_option( KEY );

notes

AS SETTER
    Scope::Session->notes( KEY => VALUE );
AS GETTER
    Scope::Session->notes( KEY );
AS ACCESSOR OF NOTE
    Scope::Session->notes->set( KEY => VALUE );
    Scope::Session->notes->get( KEY );
    Scope::Session->notes->exists( KEY );

add_error_handler($error_class,$handler)

push error handler

    Scope::Session::start {
        Scope::Session->add_error_handler( 'Error::DB::Refused' ,sub {
            # log it
        });

        # ...
        
        die with Error::DB::Refused;
    }

is_started

if in a scope session, return true value.

    Scope::Session::start {
        Scope::Session->is_started ; # 1 
    };

    Scope::Session->is_started ; # 0

AUTHOR ^

Daichi Hiroki, <hirokidaichi<AT>gmail.com>

LICENSE AND COPYRIGHT ^

Copyright 2009 Daichi Hiroki.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

syntax highlighting: