);
};
+override construct_instance => sub {
+ my ($class) = @_;
+ my $pkg = $class->name;
+
+ no strict 'refs';
+
+ # create exactly one instance
+ if (!defined ${"$pkg\::singleton"}) {
+ ${"$pkg\::singleton"} = super;
+ }
+
+ return ${"$pkg\::singleton"};
+};
+
1;
no strict 'refs';
-override new => sub {
- my $class = shift;
-
- # create exactly one instance
- if (!defined ${"$class\::singleton"}) {
- ${"$class\::singleton"} = super;
- }
-
- return ${"$class\::singleton"};
-};
-
sub instance { shift->new }
1;