projects
/
gitmo/MooseX-Singleton.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
do not allow double initialization
[gitmo/MooseX-Singleton.git]
/
lib
/
MooseX
/
Singleton
/
Object.pm
diff --git
a/lib/MooseX/Singleton/Object.pm
b/lib/MooseX/Singleton/Object.pm
index
c35c1e8
..
942e149
100644
(file)
--- a/
lib/MooseX/Singleton/Object.pm
+++ b/
lib/MooseX/Singleton/Object.pm
@@
-7,6
+7,15
@@
extends 'Moose::Object';
sub instance { shift->new }
+sub new {
+ my ($class, @args) = @_;
+
+ my $existing = $class->meta->existing_singleton;
+ confess "Singleton is already initialized" if $existing and @args;
+
+ return $class->SUPER::new(@args);
+}
+
1;
__END__