NAME
Any::Mo - load Moose or Mouse or Mo
SYNOPSIS
{
package Person;
use Any::Mo;
has name => (is => 'ro', isa => 'Str');
}
my $bob = Person->new(name => 'Bob');
DESCRIPTION
This module is quite like Any::Moose, which will use either Moose or Mouse on demand, but adds Mo to the mix.
In particular, if Moose is available and has already been require
d, then it uses Moose. Otherwise, if Mouse is available and has already been require
d, then it uses that. If all else fails, it falls back to a copy of Mo which is inlined into Any::Mo as a DATA section. (You may set the PERL_ANY_MO environment variable to force a particular choice.)
The inlined copy of Mo is based on the copy in my github fork at https://github.com/tobyink/p5-mo and has the following extensions:
Mo::coerce (will be dropped in a future version)
Mo::isa
Mo is minimal. It does not have all the features of Mouse or Moose. So if you use Any::Mo, you should take care that you're not counting on features of Mouse/Moose that Mo does not possess. This includes roles, method modifiers, metaclasses, automatic delegation and DEMOLISH. It is a good idea to run your entire test suite through three times, with PERL_ANY_MO set to "Mo", "Mouse" and "Moose", and check that it passes under all three. (At some point a Test::Any::Mo module may be written to help automate this.)
Note that another difference between Mouse/Moose and Mo, is that the former two export Carp confess
and Scalar::Util blessed
into your namespace; Mo doesn't. To smooth over the difference, Any::Mo will always make sure these two functions are exported to your namespace.
FAQ
Why no Moo?
A key requirement in "Any::Foobar" type modules is that it should be possible to use the various implementations fairly interchangably. If Moo were added to Any::Mo, this would not be the case, as Moo's implementation of isa
is quite different to Moose and Mouse.
(I'll probably drop Mo::coerce for similar reasons.)
Why no Any::Mo::Role.
Mo doesn't have any role support. If you need roles, switch to Any::Moose which comes bundled with an Any::Moose::Role module.
BUGS
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Any-Mo.
SEE ALSO
Moose and its imitators: M, Mo, Moo, Mouse, Reindeer, Acme::Elk.
AUTHOR
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE
This software is copyright (c) 2012 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.