NAME

MOP::Util - For MOP External Use Only

VERSION

version 0.14

DESCRIPTION

This is a public API of MOP related utility functions.

METHODS

get_meta( $package )

First this will check to see if $package has a METACLASS method, and if so, will use it to construct the metaclass and return it to you.

If no METACLASS method is found, this function will next attempt to guess the most sensible type of meta object for the $package supplied.

The test is simple, if there is anything in the @ISA array inside $package, then it is clearly a class and then this function returns a MOP::Class instance. However, if there is nothing in @ISA we conservatively estimate that this is a role and then return a MOP::Role instance.

In pretty much all cases that matter, a role and a class are entirely interchangable. The only real difference is that a class has methods in the MOP for manipulating inheritance relationships (@ISA)and roles do not.

compose_roles( $meta )

This will look to see if the $meta object has any roles stored in it's @DOES array, if so it will compose the roles together and apply that result to $meta.

Note, if this is called more than once, the results are undefined.

inherit_slots( $meta )

This will look to see if the $meta object is a MOP::Class instance and if so, will then loop through the direct superclasses (thouse in the @ISA array of $meta) and alias all the slots into the $meta namespace.

Note, if this is called more than once, the results are undefined.

defer_until_UNITCHECK( $cb )

Given a CODE reference, this will defer the execution of that $cb until the next available UNITCHECK phase.

Note, it is not receommended to heavily abuse closures here, it might get messy, might not, better to keep it clean and just not go there.

AUTHOR

Stevan Little <stevan@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017, 2018 by Stevan Little.

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