NAME
Mite::Manual::Missing - major Moose features not supported by Mite
MANUAL
Run-Time Class/Role Building
Your constructor, destructor, and accessors are build on the developer's machine when mite compile
is run, rather than at run-time on the end user's machine like Moose, Mouse, and Moo do. Role application is mostly performed during mite compile
too, with the exception of applying method modifiers, and checking that requires
is satisfied, which happens at run-time.
This means any run-time logic used to construct your classes and roles is unlikely to work. As an example:
package Your::Project::SomeClass;
use Your::Project::Mite;
if ( $ENV{YOUR_PROJECT_DEBUG} ) {
with 'Your::Project::Trait::Verbose';
}
...;
1;
Best case scenario, this will work, but it's the value of YOUR_PROJECT_DEBUG
on the developer's machine when they run mite compile
which is honoured, and becomes hard-coded into the generated class. Worst case scenario, things break in interesting and unusual ways.
Logic which is guaranteed to run the same on both the developer's machine and the end user's machine should be fine. For example, this should be fine:
for my $attr ( qw( foo bar baz ) ) {
has $attr => (
reader => "get_$attr",
writer => "set_$attr",
);
}
However Mite provides a lot of shortcuts which Moose doesn't, so you're less likely to need that sort of logic anyway. You could just write:
has [ qw( foo bar baz ) ] => (
reader => 'get_%s',
writer => 'set_%s',
);
Or even:
has [ qw( foo bar baz ) ] => (
reader => true,
writer => true,
);
And it will work the same!
If you do need to be able to construct your classes and roles at run time, switch to Moose or Moo.
BUGS
Please report any bugs to https://github.com/tobyink/p5-mite/issues.
AUTHOR
Michael G Schwern <mschwern@cpan.org>.
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE
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.
DISCLAIMER OF WARRANTIES
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.