1 package MooseX::StrictConstructor::Trait::Class;
3 # applied as class_metaroles => { class => [ __PACKAGE__ ] }, for Moose 1.99x and later
7 use namespace::autoclean;
11 around '_inline_BUILDALL' => sub {
15 my @source = $self->$orig();
19 map { B::perlstring($_) . ' => 1,' }
21 map { $_->init_arg() } $self->get_all_attributes()
26 'my %attrs = (' . ( join ' ', @attrs ) . ');',
27 'my @bad = sort grep { !$attrs{$_} } keys %{ $params };',
29 'Moose->throw_error("Found unknown attribute(s) passed to the constructor: @bad");',
36 # ABSTRACT: A role to make immutable constructors strict
44 This role simply wraps C<_inline_BUILDALL()> (from
45 C<Moose::Meta::Class>) so that immutable classes have a