# no actual benefits.
$_->meta->make_immutable(
- ( $_->can("_new") ? (
- inline_constructor => 1,
- constructor_name => "_new",
- ) : (
- inline_constructor => 0,
- ) ),
+ inline_constructor => 1,
+ replace_constructor => 1,
+ constructor_name => "_new",
inline_accessors => 0,
) for qw/
Class::MOP::Package
package_name => $metaclass->name,
name => $options{constructor_name}
)
- ) unless $metaclass->has_method($options{constructor_name});
+ ) if $options{replace_constructor} or !$metaclass->has_method($options{constructor_name});
}
if ($options{inline_destructor}) {
Class::MOP::Class->initialize(blessed($_[0]) || $_[0]);
}
+sub _new {
+ my ( $class, @args ) = @_;
+ Class::MOP::Class->initialize($class)->new_object(@args);
+}
+
# RANT:
# Cmon, how many times have you written
# the following code while debugging:
use strict;
use warnings;
-use Test::More tests => 224;
+use Test::More tests => 230;
use Test::Exception;
BEGIN {
isa_ok($class_mop_module_meta, 'Class::MOP::Module');
my @class_mop_package_methods = qw(
+ _new
initialize
);
my @class_mop_module_methods = qw(
+ _new
version authority identifier
);
my @class_mop_class_methods = qw(
+ _new
initialize reinitialize create