package MooseX::StrictConstructor::Trait::Method::Constructor;
-use strict;
-use warnings;
+use Moose::Role;
-use B ();
-use Carp ();
+use namespace::autoclean;
-use Moose::Role;
+use B ();
around '_generate_BUILDALL' => sub {
my $orig = 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;
-};
+} if $Moose::VERSION < 1.9900;
+
+around _eval_environment => sub {
+ my $orig = shift;
+ my $self = shift;
-no Moose::Role;
+ my $env = $self->$orig();
+
+ my %attrs = map { $_ => 1 }
+ grep { defined }
+ map { $_->init_arg() }
+ $self->associated_metaclass()->get_all_attributes();
+
+ $attrs{__INSTANCE__} = 1;
+
+ $env->{'%allowed_attrs'} = \%attrs;
+
+ return $env;
+} if $Moose::VERSION >= 1.9900;
1;
=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