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;
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
=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