comments specifying how these traits are applied, just to keep it straight
[gitmo/MooseX-StrictConstructor.git] / lib / MooseX / StrictConstructor / Trait / Method / Constructor.pm
index e3dd07b..da0c4d3 100644 (file)
@@ -1,13 +1,13 @@
 package MooseX::StrictConstructor::Trait::Method::Constructor;
 
-use strict;
-use warnings;
-
-use B ();
-use Carp ();
+# applied as class_metaroles => { constructor => [ __PACKAGE__ ] }, for older Moose
 
 use Moose::Role;
 
+use namespace::autoclean;
+
+use B ();
+
 around '_generate_BUILDALL' => sub {
     my $orig = shift;
     my $self = shift;
@@ -28,15 +28,13 @@ my \%attrs = (@attrs);
 my \@bad = sort grep { ! \$attrs{\$_} }  keys \%{ \$params };
 
 if (\@bad) {
-    Carp::confess "Found unknown attribute(s) passed to the constructor: \@bad";
+    Moose->throw_error("Found unknown attribute(s) passed to the constructor: \@bad");
 }
 EOF
 
     return $source;
 };
 
-no Moose::Role;
-
 1;
 
 # ABSTRACT: A role to make immutable constructors strict
@@ -45,16 +43,6 @@ __END__
 
 =pod
 
-=head1 SYNOPSIS
-
-  Moose::Util::MetaRole::apply_metaroles(
-      for_class => $caller,
-      class     => {
-          constructor =>
-              ['MooseX::StrictConstructor::Trait::Method::Constructor'],
-      },
-  );
-
 =head1 DESCRIPTION
 
 This role simply wraps C<_generate_BUILDALL()> (from