{{$NEXT}}
+- Throw an error when used by a non-class; it won't do what users think
+
0.16 2011-04-22
- Don't wrap BUILDALL, since this breaks if the object doesn't inherit from
Moose::Exporter->setup_import_methods(
class_metaroles => \%class_meta,
);
+
+ my $old_import = __PACKAGE__->can('import');
+ no warnings 'redefine';
+ *import = sub {
+ my $caller = caller;
+ Carp::croak "$_[0] can only be applied to Moose classes"
+ unless eval { $caller->meta->isa('Moose::Meta::Class') };
+
+ goto &$old_import;
+ };
}
1;
has 'size' => ( is => 'rw', 'init_arg' => undef );
}
+{
+ local $@;
+ eval q[package MyRole; use Moose::Role; use MooseX::StrictConstructor;];
+ like(
+ $@,
+ qr/can only be applied to Moose classes/,
+ "can't apply MXSC to a role"
+ );
+}
+
+{
+ local $@;
+ eval q[package Nothing; use MooseX::StrictConstructor;];
+ like(
+ $@,
+ qr/can only be applied to Moose classes/,
+ "can't apply MXSC to a random package",
+ );
+}
+
my @classes
= qw( Standard Stricter Subclass StrictSubclass OtherStrictSubclass Tricky InitArg );