Update Changes
[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
5a0d4921 8after 'BUILDALL' => sub {
32726d88 9 my $self = shift;
10 my $params = shift;
11
5a0d4921 12 my %attrs = (
13 map { $_ => 1 }
14 grep {defined}
15 map { $_->init_arg() } $self->meta()->get_all_attributes()
16 );
32726d88 17
5a0d4921 18 my @bad = sort grep { !$attrs{$_} } keys %{$params};
32726d88 19
5a0d4921 20 if (@bad) {
21 confess
22 "Found unknown attribute(s) init_arg passed to the constructor: @bad";
32726d88 23 }
24
25 return;
26};
27
0cdff431 28no Moose::Role;
32726d88 29
301;
2ffa7b60 31
32__END__
33
34=pod
35
36=head1 NAME
37
ab80b917 38MooseX::StrictConstructor::Role::Object - A role which implements a strict constructor for Moose::Object
39
40=head1 SYNOPSIS
41
42 Moose::Util::MetaRole::apply_base_class_roles
43 ( for_class => $caller,
44 roles =>
45 [ 'MooseX::StrictConstructor::Role::Object' ],
46 );
2ffa7b60 47
48=head1 DESCRIPTION
49
fbfaa61f 50When you use C<MooseX::StrictConstructor>, your objects will have this
51role applied to them. It provides a method modifier for C<BUILDALL()>
52from C<Moose::Object> that implements strict argument checking for
53your class.
2ffa7b60 54
55=head1 AUTHOR
56
57Dave Rolsky, C<< <autarch@urth.org> >>
58
59=head1 COPYRIGHT & LICENSE
60
fbfaa61f 61Copyright 2007-2008 Dave Rolsky, All Rights Reserved.
2ffa7b60 62
63This program is free software; you can redistribute it and/or modify
64it under the same terms as Perl itself.
65
66=cut