X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Singleton.git;a=blobdiff_plain;f=lib%2FMooseX%2FSingleton%2FObject.pm;h=e13457bef50c0a1057afe33bc42a45c61ea3ec6b;hp=8ad2a4dd7fe31eb1e3d807e1f049fd9afcdc78c2;hb=963b26bdbceabdfb30dac57a85d95fec1e9d925d;hpb=1bffae4e6593ddc6d337698340ca6dbb1601a0db diff --git a/lib/MooseX/Singleton/Object.pm b/lib/MooseX/Singleton/Object.pm index 8ad2a4d..e13457b 100644 --- a/lib/MooseX/Singleton/Object.pm +++ b/lib/MooseX/Singleton/Object.pm @@ -22,6 +22,10 @@ sub new { my $existing = $class->meta->existing_singleton; confess "Singleton is already initialized" if $existing and @args; + # Otherwise BUILD will be called repeatedly on the existing instance. + # -- rjbs, 2008-02-03 + return $existing if $existing and ! @args; + return $class->SUPER::new(@args); }