From: Dave Rolsky Date: Wed, 18 May 2011 18:42:18 +0000 (-0500) Subject: Revert "MXSC must be used by Moose classes, nothing else" X-Git-Tag: v0.17~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b98b8f867754f1c69f1cae8ac1b6fc0bb2544e3a;p=gitmo%2FMooseX-StrictConstructor.git Revert "MXSC must be used by Moose classes, nothing else" This reverts commit 4a070866bc7b2cf1792322865e0c7997ef7401a3. --- diff --git a/Changes b/Changes index 985bf3e..9590625 100644 --- a/Changes +++ b/Changes @@ -1,7 +1,5 @@ {{$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 diff --git a/lib/MooseX/StrictConstructor.pm b/lib/MooseX/StrictConstructor.pm index 80e8453..40fa4bb 100644 --- a/lib/MooseX/StrictConstructor.pm +++ b/lib/MooseX/StrictConstructor.pm @@ -20,16 +20,6 @@ use Moose::Util::MetaRole; 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; diff --git a/t/basic.t b/t/basic.t index b159e77..f69201f 100644 --- a/t/basic.t +++ b/t/basic.t @@ -80,26 +80,6 @@ use Test::More; 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 );