use Moose->throw_error rather than confess
[gitmo/MooseX-StrictConstructor.git] / lib / MooseX / StrictConstructor / Role / Object.pm
index f755234..4b5a765 100644 (file)
@@ -1,15 +1,15 @@
 package MooseX::StrictConstructor::Role::Object;
 
-use strict;
-use warnings;
-
 use Moose::Role;
 
+use namespace::autoclean;
+
 after 'BUILDALL' => sub {
     my $self   = shift;
     my $params = shift;
 
     my %attrs = (
+        __INSTANCE__ => 1,
         map { $_ => 1 }
         grep {defined}
         map  { $_->init_arg() } $self->meta()->get_all_attributes()
@@ -18,15 +18,13 @@ after 'BUILDALL' => sub {
     my @bad = sort grep { !$attrs{$_} } keys %{$params};
 
     if (@bad) {
-        confess
-            "Found unknown attribute(s) init_arg passed to the constructor: @bad";
+        Moose->throw_error(
+            "Found unknown attribute(s) init_arg passed to the constructor: @bad");
     }
 
     return;
 };
 
-no Moose::Role;
-
 1;
 
 # ABSTRACT: A role which implements a strict constructor for Moose::Object
@@ -37,11 +35,11 @@ __END__
 
 =head1 SYNOPSIS
 
-  Moose::Util::MetaRole::apply_base_class_roles
-      ( for_class => $caller,
-        roles =>
-        [ 'MooseX::StrictConstructor::Role::Object' ],
-      );
+  Moose::Util::MetaRole::apply_base_class_roles(
+      for_class => $caller,
+      roles =>
+          ['MooseX::StrictConstructor::Role::Object'],
+  );
 
 =head1 DESCRIPTION