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");',
34 # if the Object role is applied first, and then a superclass added, we just
35 # lost our BUILDALL modification.
36 after superclasses => sub
40 Moose::Util::MetaRole::apply_base_class_roles(
42 roles => ['MooseX::StrictConstructor::Role::Object'],
48 # ABSTRACT: A role to make immutable constructors strict
56 This role simply wraps C<_inline_BUILDALL()> (from
57 C<Moose::Meta::Class>) so that immutable classes have a