# the author, after all, nothing is free)
my $source = 'sub {';
$source .= "\n" . 'my $class = shift;';
-
- $source .= "\n" . 'my $existing = do { no strict "refs"; \${"$class\::singleton"}; };';
+
+ $source .= "\n" . 'my $existing = do { no strict "refs"; no warnings "once"; \${"$class\::singleton"}; };';
$source .= "\n" . 'return ${$existing} if ${$existing};';
$source .= "\n" . 'return $class->Moose::Object::new(@_)';
my $code;
{
+ my $meta = $self;
+
# NOTE:
# create the nessecary lexicals
# to be picked up in the eval
} @type_constraints;
$code = eval $source;
- confess "Could not eval the constructor :\n\n$source\n\nbecause :\n\n$@" if $@;
+ $self->throw_error(
+ "Could not eval the constructor :\n\n$source\n\nbecause :\n\n$@",
+ error => $@, data => $source )
+ if $@;
}
- $self->{'&!body'} = $code;
+ $self->{'body'} = $code;
+}
+
+sub _expected_constructor_class {
+ return 'MooseX::Singleton::Object';
}
no Moose;