The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

ScopeSession - a scope based object note and option store

VERSION

Version 0.01

SYNOPSIS

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

    use ScopeSession;

    ScopeSession::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 ScopeSession. It is unique in the block called at ScopeSession::start.

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

set_option

to set a session unique option value

    ScopeSession->set_option( KEY => VALUE )
    

get_option

to get a session unique option value

    ScopeSession->get_option( KEY );

notes

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

add_error_handler($error_class,$handler)

push error handler

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

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

is_started

ask to be in a session.

    ScopeSession::start {
        ScopeSession->is_started ; # 1 
    };

    ScopeSession->is_started ; # 0

AUTHOR

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

BUGS

Please report any bugs or feature requests to bug-scopesession at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=ScopeSession. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc ScopeSession

You can also look for information at:

ACKNOWLEDGEMENTS

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.