use Moose 0.94 ();
use Moose::Exporter;
use Moose::Util::MetaRole;
-use MooseX::StrictConstructor::Role::Object;
-use MooseX::StrictConstructor::Role::Meta::Class;
-use MooseX::StrictConstructor::Role::Meta::Method::Constructor;
-
-Moose::Exporter->setup_import_methods(
- class_metaroles => {
- ($Moose::VERSION >= 1.9900
- ? (class => ['MooseX::StrictConstructor::Role::Meta::Class'])
- : (constructor => ['MooseX::StrictConstructor::Role::Meta::Method::Constructor'])),
- },
- base_class_roles => ['MooseX::StrictConstructor::Role::Object'],
-);
+
+{
+ my %class_meta = ( class => ['MooseX::StrictConstructor::Trait::Class'] );
+
+ if ( $Moose::VERSION < 1.9900 ) {
+ require MooseX::StrictConstructor::Trait::Method::Constructor;
+ $class_meta{constructor}
+ = ['MooseX::StrictConstructor::Trait::Method::Constructor'];
+ }
+
+ Moose::Exporter->setup_import_methods(
+ class_metaroles => \%class_meta,
+ );
+}
1;
Simply loading this module makes your constructors "strict". If your
constructor is called with an attribute init argument that your class
-does not declare, then it calls "Carp::confess()". This is a great way
+does not declare, then it calls C<Moose->throw_error()>. This is a great way
to catch small typos.
=head2 Subverting Strictness