X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FObject%2FStrictConstructor.pm;h=55b5d91c0391252fd5fcf723c3bf610856dcdd5c;hb=a83dec4353207816d24e09f0f3a7afc2200369c4;hp=c21a667d36507f470fc9f84ac3ea032f799e3857;hpb=2ffa7b600545d76ba73216e6f158ea47b984fb3e;p=gitmo%2FMooseX-StrictConstructor.git diff --git a/lib/MooseX/Object/StrictConstructor.pm b/lib/MooseX/Object/StrictConstructor.pm index c21a667..55b5d91 100644 --- a/lib/MooseX/Object/StrictConstructor.pm +++ b/lib/MooseX/Object/StrictConstructor.pm @@ -7,6 +7,9 @@ use Moose; use Carp 'confess'; +use metaclass 'MooseX::StrictConstructor::Meta::Class'; + + extends 'Moose::Object'; after 'BUILDALL' => sub @@ -14,13 +17,18 @@ after 'BUILDALL' => sub my $self = shift; my $params = shift; - my %attrs = map { $_->name() => 1 } $self->meta()->compute_all_applicable_attributes(); + my %attrs = + ( map { $_ => 1 } + grep { defined } + map { $_->init_arg() } + $self->meta()->compute_all_applicable_attributes() + ); - my @bad = grep { ! $attrs{$_} } keys %{ $params }; + my @bad = sort grep { ! $attrs{$_} } keys %{ $params }; if (@bad) { - confess "Found unknown attribute(s) passed to the constructor: @bad"; + confess "Found unknown attribute(s) init_arg passed to the constructor: @bad"; } return;