Adam Kennedy > Aspect-1.04 > Aspect::Library::Singleton

Download:
Aspect-1.04.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  1
View/Report Bugs
Module Version: 1.04   Source  

NAME ^

Aspect::Library::Singleton - A singleton aspect

SYNOPSIS ^

  use Aspect;
  use Aspect::Singleton;
  
  aspect Singleton => 'Foo::new';
  
  my $f1 = Foo->new;
  my $f2 = Foo->new;
  
  # Both $f1 and $f2 refer to the same object

DESCRIPTION ^

A reusable aspect that forces singleton behavior on a constructor. The constructor is defined by a pointcut spec: a string. regexp, or code ref.

It is slightly different from Class::Singleton (http://search.cpan.org/~abw/Class-Singleton/Singleton.pm):

Note that this is just a special case of memoizing.

AUTHORS ^

Adam Kennedy <adamk@cpan.org>

Marcel Grünauer <marcel@cpan.org>

Ran Eilam <eilara@cpan.org>

COPYRIGHT ^

Copyright 2001 by Marcel Grünauer

Some parts copyright 2009 - 2013 Adam Kennedy.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: