Mite::Manual::Features - other features provided by Mite
Your class can or will provide the following methods:
new( %attributes )
new( \%attributes )
Constructor for your class. It takes some arguments and returns an object.
Mite generates this for you.
Mite automatically provides a similar feature to MooseX::StrictConstructor, so your constructor will die if you pass it unknown attributes.
BUILDARGS
Works as in Moose and allows your constructor to be called with something other than a hash of attributes. Mite does not generate this for you.
FOREIGNBUILDARGS
Works as in Moo and MooseX::NonMoose. Mite does not generate this for you.
BUILD
BUILDALL
Works as in Moose. Mite generates BUILDALL for you.
From Mite 0.007004 onwards, your BUILD method gets called before the strict constructor check, which allows you to remove keys from $args if you don't want them to trigger an exception.
$args
DEMOLISH
DESTROY
Works as in Moose. Mite generates DESTROY for you.
On Perl older than 5.14, the $in_global_destruction argument will be undefined unless Devel::GlobalDestruction is installed, so add that to your project's dependencies if you are relying on it and need to support older versions of Perl.
$in_global_destruction
DOES
does
DOES allows you to check if your class/object performs a particular role. See UNIVERSAL.
does is just an alias.
If you want to fake support for a role:
$Your::Project::SomeClass::DOES{'Your::Project::SomeRole'} = 1;
strict
Mite will turn strict on for you.
warnings
Mite will turn warnings on for you.
Mite will automatically import namespace::autoclean into your classes if it is installed on the end user's system. If it's not available, your classes will quietly be left with imported keywords cluttering up their namespace.
To force namespace::autoclean, then just use it manually:
use Your::Project::Mite; use namespace::autoclean;
To force it to not be used:
use Your::Project::Mite qw( -unclean );
Autolax mode can be enabled in your .mite/config file:
autolax: 1
If you do that and recompile your project, then many of the sanity checks Mite builds into your constructors, accessors, and method signatures will be disabled by default. In lax mode, these checks will be disabled:
MooseX::StrictConstructor-style checks for unknown named parameters passed to your constructor.
Checks for unknown named parameters passed to method signatures.
Type checks in your constructor, except as part of coercion.
Type checks in accessors and writers, except as part of coercion.
Type checks in method signatures, except as part of coercion.
Argument count checks in readers, writers, accessors, lvalue accessors, clearers, and predicates.
Argument count checks in method signatures.
However, while the checks become disabled, they can be re-enabled by the end user by setting the PERL_STRICT environment variable, or any other environment variable supported by Devel::StrictMode.
PERL_STRICT
The idea is that if your project uses autolax, you can set PERL_STRICT in your testing environment to get more rigorous checks, fix any errors you find, and then run your code without PERL_STRICT in your production environment.
Please report any bugs to https://github.com/tobyink/p5-mite/issues.
Michael G Schwern <mschwern@cpan.org>.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2011-2014 by Michael G Schwern.
This software is copyright (c) 2022 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install Mite, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mite
CPAN shell
perl -MCPAN -e shell install Mite
For more information on module installation, please visit the detailed CPAN module installation guide.