Class-StrongSingleton
view release on metacpan or search on metacpan
lib/Class/StrongSingleton.pm view on Meta::CPAN
our $VERSION = '0.02';
my %instances;
my %constructors;
## protected initializer
sub _init_StrongSingleton {
# do not let us be called by anything which
# is not derived from Class::StrongSingleton
(UNIVERSAL::isa((caller)[0], 'Class::StrongSingleton'))
|| die "Illegal Operation : _init_StrongSingleton can only be called by a subclass of Class::StrongSingleton";
my ($self) = @_;
(ref($self))
|| die "Illegal Operation : _init_StrongSingleton can only be called as an instance method";
# get the class name
my $class = ref($self);
(!exists($instances{$class}))
|| die "Illegal Operation : cannot call _init_StrongSingleton with a valid Singleton instance";
# assuming new was the name of our
# constructor, otherwise ...
( run in 0.285 second using v1.01-cache-2.11-cpan-1e74a51a04c )