package MooseX::Singleton::Meta::Class;
use Moose;
use MooseX::Singleton::Meta::Instance;
+use MooseX::Singleton::Meta::Method::Constructor;
extends 'Moose::Meta::Class';
my $class = shift;
my $pkg = shift;
- $class->SUPER::initialize(
+ my $self = $class->SUPER::initialize(
$pkg,
instance_metaclass => 'MooseX::Singleton::Meta::Instance',
+ constructor_class => 'MooseX::Singleton::Meta::Method::Constructor',
@_,
);
-};
+
+ return $self;
+}
sub existing_singleton {
my ($class) = @_;
return;
}
-override construct_instance => sub {
+override _construct_instance => sub {
my ($class) = @_;
# create exactly one instance
return ${"$pkg\::singleton"} = super;
};
-# Need to remove make_immutable before we define it below
no Moose;
-use MooseX::Singleton::Meta::Method::Constructor;
-
-sub make_immutable {
- my $self = shift;
- $self->SUPER::make_immutable
- (
- constructor_class => 'MooseX::Singleton::Meta::Method::Constructor',
- @_,
- );
-}
-
1;
__END__