Moose::...MetaRole(3)
π Moose::Util::MetaRole β the manual page, bestie edition π
okay so this is Moose::Util::MetaRole(3), straight out of the User Contributed Perl Documentation collection. yes it's a real manual page, yes it's about metaclasses, no you don't have to be scared. sit down, grab a boba, we're doing this together π§β¨
πΈ NAME πΈ
Moose::Util::MetaRole β apply roles to any metaclass, and also to the object base class. like, any of them. all of them. go off π
β VERSION β
version 2.4000 β that's the one, that's the version, don't @ me π
β¨ SYNOPSIS β¨
here's the whole vibe in code form, copied exactly, no notes:
package MyApp::Moose;
use Moose ();
use Moose::Exporter;
use Moose::Util::MetaRole;
use MyApp::Role::Meta::Class;
use MyApp::Role::Meta::Method::Constructor;
use MyApp::Role::Object;
Moose::Exporter->setup_import_methods( also => 'Moose' );
sub init_meta {
shift;
my %args = @_;
Moose->init_meta(%args);
Moose::Util::MetaRole::apply_metaroles(
for => $args{for_class},
class_metaroles => {
class => ['MyApp::Role::Meta::Class'],
constructor => ['MyApp::Role::Meta::Method::Constructor'],
},
);
Moose::Util::MetaRole::apply_base_class_roles(
for => $args{for_class},
roles => ['MyApp::Role::Object'],
);
return $args{for_class}->meta();
}
look at her. so structured. so iconic π
π¦ DESCRIPTION π¦
so this utility module exists to help authors of Moose extensions write extensions that can actually cooperate with other Moose extensions. no beef, no drama, just teamwork. and the way you do that is: you write your extensions as roles, and then those roles get dynamically applied to the caller's metaclasses. periodt π«
the way this module is so thoughtful is that it makes sure to preserve any existing superclasses and roles already set for the meta objects. which means β and this is the slay part β any number of extensions can apply roles in any order. no cap. it just works π
π USAGE π
the easiest way to use this module, fr fr, is through Moose::Exporter. that guy can generate the appropriate init_meta method for you, and also make sure it gets called when imported. let him cook π³
π FUNCTIONS π
this module provides two functions. two. that's it. we love a small API π
π apply_metaroles( ... ) π
this function will apply roles to one or more metaclasses for the specified class. and it returns a new metaclass object for the class or role you passed in the for parameter. brand new object, fresh out the box π
it accepts the following parameters:
for => $nameβ this specifies the class for which to alter the meta classes. it can be a package name, or an appropriate meta-object (aMoose::Meta::ClassorMoose::Meta::Role). so like, either the name-name or the whole object, your call bestie π«Άclass_metaroles => \%rolesβ this is a hash reference specifying which metaroles will be applied to the class metaclass and its contained metaclasses and helper classes. each key should in turn point to an array reference of role names.
it accepts the following keys:
classattributemethodwrapped_methodinstanceconstructordestructorerror
that's the whole list. all eight of them. count them if you want, they're all there π
role_metaroles => \%rolesβ this is a hash reference specifying which metaroles will be applied to the role metaclass and its contained metaclasses and helper classes.
it accepts the following keys:
roleattributemethodrequired_methodconflicting_methodapplication_to_classapplication_to_roleapplication_to_instanceapplication_role_summationapplied_attribute
yes, ten. ten whole keys. she's thorough, she's committed, she ate π₯
π apply_base_class_roles( for => $class, roles => @roles ) π
this function will apply the specified roles to the object's base class. that's the whole description. short, sweet, done. it's giving main character with minimal dialogue π
π BUGS π
see "BUGS" in Moose for details on reporting bugs. go tell Moose, not me, i'm just the messenger π
π AUTHORS π
these are the legends who built this. absolute icons, every single one:
- Stevan Little <stevan@cpan.org>
- Dave Rolsky <autarch@urth.org>
- Jesse Luehrs <doy@cpan.org>
- Shawn M Moore <sartak@cpan.org>
- ΧΧΧΧ Χ§ΧΧ'ΧΧ (Yuval Kogman) <nothingmuch@woobling.org>
- Karen Etheridge <ether@cpan.org>
- Florian Ragwitz <rafl@debian.org>
- Hans Dieter Pearcey <hdp@cpan.org>
- Chris Prather <chris@prather.org>
- Matt S Trout <mstrout@cpan.org>
ten authors. ten. collaborative queen behavior fr fr πΈ
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2006 by Infinity Interactive, Inc.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. so like, go forth, remix, redistribute, it's all legal and it's all yours π«Ά
okay that's the whole page bestie!! and before you go β this was perl v5.42.0, dated 2025-07-25, and that's the footer, so consider yourself properly signed off β¨ bye ily, go apply some roles to some metaclasses responsibly π
ππ¦
π¦ where this page comes from
- fedora 43: perl-Moose 2.4000-4.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms