view Lib/IMPL/Object/Singleton.pm @ 59:0f3e369553bd

Rewritten property implementation (probably become slower but more flexible) Configuration infrastructure in progress (in the aspect of the lazy activation) Initial concept for the code generator
author wizard
date Tue, 09 Mar 2010 02:50:45 +0300
parents 16ada169ca75
children 0d2337e203c0
line wrap: on
line source

package IMPL::Object::Singleton;
use strict;
use warnings;

my %instances;

sub instance {
    my $self = shift;
    
    $instances{$self} || ($instances{$self} = $self->new(@_));
}

1;

__END__

=pod

=head1 SYNOPSIS

package Foo;

use base qw(IMPL::Object IMPL::Object::Singleton);

#....

Foo->isnatnce->some_work();

Foo->isnatnce->get_result();

=head1 DESCRIPTION

Реализует шаблон Singleton

=head1 MEMBERS

=head2 OPERATORS

=list

=item C<instance CLASS(@params)>

Создает или возвращает экземпляр класса, если экземляр не существует, то он создается с параметрами C<@params>.

=over

=cut