The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Scope::Session::Flyweight - Attach light-weight instance creation for Scope::Session

VERSION

Version 0.01

SYNOPSIS

work as factory

    use Scope::Session::Flyweight;
    my $flyweight
        = Scope::Session::Flyweight->acquire( q|Test::Object| => ( id => 10 ) );
    my $flyweight2
        = Scope::Session::Flyweight->acquire( q|Test::Object| => ( id => 10 ) );

work as role

    package Test::Object;
    use Scope::Session::Flyweight acquire => 1;
    sub identifier {
        my ( $class, %args ) = @_;
        return $args{id};
    }
    sub new {
        my ( $class, %args ) = @_;
        return bless {%args} => $class;
    }
    my $flyweight  = Test::Object->acquire( id => 10 );
    my $flyweight2 = Test::Object->acquire( id => 10 );

METHODS

acquire

TARGET CLASS

target class must be implemented following methods.

indentifier

get constructor options and return object identity string.

new

create instance

get a same identifier instance

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.