Tidy synopsis
[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 = (
d78f8e74 13 __INSTANCE__ => 1,
5a0d4921 14 map { $_ => 1 }
15 grep {defined}
16 map { $_->init_arg() } $self->meta()->get_all_attributes()
17 );
32726d88 18
5a0d4921 19 my @bad = sort grep { !$attrs{$_} } keys %{$params};
32726d88 20
5a0d4921 21 if (@bad) {
22 confess
23 "Found unknown attribute(s) init_arg passed to the constructor: @bad";
32726d88 24 }
25
26 return;
27};
28
0cdff431 29no Moose::Role;
32726d88 30
311;
2ffa7b60 32
0639c294 33# ABSTRACT: A role which implements a strict constructor for Moose::Object
34
2ffa7b60 35__END__
36
37=pod
38
ab80b917 39=head1 SYNOPSIS
40
fd098db8 41 Moose::Util::MetaRole::apply_base_class_roles(
42 for_class => $caller,
43 roles =>
44 ['MooseX::StrictConstructor::Role::Object'],
45 );
2ffa7b60 46
47=head1 DESCRIPTION
48
fbfaa61f 49When you use C<MooseX::StrictConstructor>, your objects will have this
50role applied to them. It provides a method modifier for C<BUILDALL()>
51from C<Moose::Object> that implements strict argument checking for
52your class.
2ffa7b60 53
2ffa7b60 54=cut