Commit | Line | Data |
---|---|---|
c001451a | 1 | package MooseX::StrictConstructor::Meta::Method::Constructor; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
5c3f24ed | 6 | use Carp (); |
c001451a | 7 | use Moose; |
8 | ||
9 | extends 'Moose::Meta::Method::Constructor'; | |
10 | ||
5c3f24ed | 11 | # using |
c001451a | 12 | sub _generate_BUILDALL ## no critic RequireArgUnpacking |
13 | { | |
14 | my $self = shift; | |
15 | ||
5c3f24ed | 16 | my $source = $self->SUPER::_generate_BUILDALL(@_); |
17 | $source .= ";\n" if $source; | |
c001451a | 18 | |
5c3f24ed | 19 | my @attrs = map { $_->name() . ' => 1,' } @{ $self->attributes() }; |
c001451a | 20 | |
5c3f24ed | 21 | $source .= <<"EOF"; |
22 | my \%attrs = (@attrs); | |
c001451a | 23 | |
5c3f24ed | 24 | my \@bad = sort grep { ! \$attrs{\$_} } keys \%params; |
25 | ||
26 | if (\@bad) { | |
27 | Carp::confess "Found unknown attribute(s) passed to the constructor: \@bad"; | |
28 | } | |
c001451a | 29 | EOF |
30 | ||
5c3f24ed | 31 | return $source; |
c001451a | 32 | }; |
33 | ||
34 | ||
35 | 1; |