initial import
[gitmo/MooseX-StrictConstructor.git] / lib / MooseX / Object / StrictConstructor.pm
1 package MooseX::Object::StrictConstructor;
2
3 use strict;
4 use warnings;
5
6 use Moose;
7
8 use Carp 'confess';
9
10 extends 'Moose::Object';
11
12 after 'BUILDALL' => sub
13 {
14     my $self   = shift;
15     my $params = shift;
16
17     my %attrs = map { $_->name() => 1 } $self->meta()->compute_all_applicable_attributes();
18
19     my @bad = grep { ! $attrs{$_} } keys %{ $params };
20
21     if (@bad)
22     {
23         confess "Found unknown attribute(s) passed to the constructor: @bad";
24     }
25
26     return;
27 };
28
29
30 1;