MOP::Util - For MOP External Use Only
version 0.12
This is a public API of MOP related utility functions.
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.
$package
METACLASS
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.
@ISA
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.
$meta
@DOES
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.
defer_until_UNITCHECK( $cb )
Given a CODE reference, this will defer the execution of that $cb until the next available UNITCHECK phase.
$cb
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.
Stevan Little <stevan@cpan.org>
This software is copyright (c) 2017 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.
To install MOP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MOP
CPAN shell
perl -MCPAN -e shell install MOP
For more information on module installation, please visit the detailed CPAN module installation guide.