NAME

Mooish::Base - importer for Mooish classes

SYNOPSIS

# for classes
use Mooish::Base;

# for roles
use Mooish::Base -role;

# create your class / role as usual

DESCRIPTION

This module is a shortcut that does roughly the same as calling these imports:

use Moo;
use Mooish::AttributeBuilder;
use Types::Common -types;
use namespace::autoclean;

# additional optional modules, if they are installed

If a -role flag is specified, then the module imports Moo::Role instead.

Environmental variables MOOISH_BASE_FLAVOUR and MOOISH_BASE_ROLE_FLAVOUR can be used to modify class and role systems used. If not present, Moo and Moo::Role will be used respectively. Make sure to introduce these variables before first loading the module.

The purpose of this module is to make it easier to create classes based on Moose family of modules. The choice of imported modules is meant to provide a solid base for module development, but still be perfectly compatible at least with Moose, Mouse and Moo.

Extra modules or features loaded

Depending on MOOISH_BASE_FLAVOUR some extra modules will be imported (if installed). Only modules which do not change the behavior will ever be added to this list - mostly modules which improve performance for free.

Moo

Moose

  • MooseX::XSAccessor

    This module attempts to use Class::XSAccessor to speed up the accessors.

  • Hook::AfterRuntime

    Since the module attempts to deliver a unified API for each flavour of Moose, Moose itself must be made immutable automatically after the class is built. This is done with the help of this module. Mooish::Base will warn if this module is not installed and Moose flavour is used.

For module authors

If you wish to use Mooish::Base in your module, please use it with -standard flag. This flag will prevent custom behavior from propagating into the module. Currently, it will only cause Mooish::AttributeBuilder to be imported with -standard flag. If some other custom behavior prove undesirable in the future, it may be included as well.

Please be aware that having a variable OO engine may not be good for all modules. Obvious example of where it is bad is the case where your code mixes in roles which were not written using Mooish::Base. If this ever becomes a pressing problem, a way to force flavour (regardless of environmental flags) may be added in the future, and it may be included as a part of -standard flag behavior. If you expect your code to be sensitive to changes in the flavour environmental flag, avoid depending on this module in your module.

SEE ALSO

Moo

Mooish::AttributeBuilder

Types::Common

Import::Into

AUTHOR

Bartosz Jarzyna <bbrtj.pro@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2025 by Bartosz Jarzyna

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.