Make sure to preserve existing metaclass settings for the old meta
[gitmo/MooseX-StrictConstructor.git] / lib / MooseX / StrictConstructor / Role / Object.pm
CommitLineData
0cdff431 1package MooseX::StrictConstructor::Role::Object;
32726d88 2
3use strict;
4use warnings;
5
0cdff431 6use Moose::Role;
32726d88 7
32726d88 8
9after 'BUILDALL' => sub
10{
11 my $self = shift;
12 my $params = shift;
13
a83dec43 14 my %attrs =
15 ( map { $_ => 1 }
16 grep { defined }
17 map { $_->init_arg() }
18 $self->meta()->compute_all_applicable_attributes()
19 );
32726d88 20
d692165d 21 my @bad = sort grep { ! $attrs{$_} } keys %{ $params };
32726d88 22
23 if (@bad)
24 {
a83dec43 25 confess "Found unknown attribute(s) init_arg passed to the constructor: @bad";
32726d88 26 }
27
28 return;
29};
30
0cdff431 31no Moose::Role;
32726d88 32
331;
2ffa7b60 34
35__END__
36
37=pod
38
39=head1 NAME
40
41MooseX::Object::StrictConstructor - Implements strict constructors as a Moose::Object subclass
42
43=head1 DESCRIPTION
44
45This class has no external interface. When you use
46C<MooseX::StrictConstructor>, your objects will subclass this class
47rather than Moose::Object.
48
49=head1 AUTHOR
50
51Dave Rolsky, C<< <autarch@urth.org> >>
52
53=head1 COPYRIGHT & LICENSE
54
55Copyright 2007 Dave Rolsky, All Rights Reserved.
56
57This program is free software; you can redistribute it and/or modify
58it under the same terms as Perl itself.
59
60=cut