diff Lib/IMPL/Object/Singleton.pm @ 312:75a78cbf7dcf

View refactoring: INIT blocks are deprecated
author cin
date Mon, 29 Apr 2013 01:10:42 +0400
parents 0f59b2de72af
children
line wrap: on
line diff
--- a/Lib/IMPL/Object/Singleton.pm	Mon Apr 22 03:42:53 2013 +0400
+++ b/Lib/IMPL/Object/Singleton.pm	Mon Apr 29 01:10:42 2013 +0400
@@ -9,11 +9,12 @@
 
 __PACKAGE__->static_accessor_own(_instance => undef);
 
-my %instances;
-
-sub CTOR {
-    die IMPL::InvalidOperationException->new("Only one instance of the singleton can be created",ref $_[0])
-        if $_[0]->_instance;
+sub InitInstance {
+    my $self = shift;
+    die IMPL::InvalidOperationException->new("Only one instance of the singleton can be created", $self)
+        if $self->_instance;
+        
+    $self->_instance($self->new(@_));
 }
 
 sub instance {