MooseX...::Role(3pm)

πŸ“¦
version 0.32 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ¦‹ MooseX...::Role β€” the vibe ✨

okay bestie, so this whole page is MooseX...::Role(3pm) from the User Contributed Perl Documentation, and honestly? it's giving "tiny module, big feelings." it's the metarole role for storing code attributes. let's get into it πŸ’–

πŸ’« VERSION

version 0.32 β€” yeah, that's the one. no cap.

🌸 SYNOPSIS

look, here's the whole thing in action:

package MyRole;
use MooseX::MethodAttributes::Role;

sub foo : Bar Baz('corge') { ... }

package MyClass
use Moose;

with 'MyRole';

my $attrs = MyClass->meta->get_method('foo')->attributes; # ["Bar", "Baz('corge')"]

see how $attrs comes back as ["Bar", "Baz('corge')"]? that's the whole point of this module and it ate πŸ’…

πŸ‘‘ DESCRIPTION

so this module is a metaclass role, and it gets applied by MooseX::MethodAttributes::Role. what does that mean for you? it means you can add code attributes to methods in Moose roles. that's it. that's the gig.

and then β€” and this is the iconic part β€” those attributes can be found by introspecting the role metaclass, and they get automatically copied into any classes or roles that the role gets composed onto. automatic. no extra work. main character energy fr fr 🫢

✨ METHODS ✨

initialize

this one makes sure that the package holding your role methods does the MooseX::MethodAttributes::Role::AttrContainer role during initialisation. and that role? it's the one responsible for capturing the method attributes on the class and registering them with the metaclass. so like, initialize isn't doing the capturing itself, it's making sure the right container shows up to the party πŸŽ€

method_metaclass

this wraps the normal method and makes sure that the method metaclass performs the MooseX::MethodAttributes::Role::Meta::Method role. why do we care? because that's what lets you introspect the attributes from the method objects the MOP hands back when you're querying the metaclass. no method metaclass role, no attribute peeking. simple as πŸ¦‹


πŸ’€ CAVEATS

listen, we gotta talk about the limits, bestie. read this part.
  • currently, roles with attributes cannot have methods excluded or aliased, and they will in turn confer this property onto any roles they are composed onto. so yeah β€” it's contagious. lowkey annoying, highkey important to know before you go wild 😭

🫢 SUPPORT

bugs may be submitted through the RT bug tracker at https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-MethodAttributes (or you can just email bug-MooseX-MethodAttributes@rt.cpan.org) πŸ’Œ

there's also a mailing list available for users of this distribution, at http://lists.perl.org/list/moose.html.

and there's an irc channel available for users of this distribution too, at #moose on irc.perl.org (irc://irc.perl.org/#moose). come hang out, the people are lovely 🌈


🌟 AUTHORS

  • Florian Ragwitz <rafl@debian.org>
  • Tomas Doran <bobtfish@bobtfish.net>

the icons who made this happen πŸ‘‘


this software is copyright (c) 2009 by Florian Ragwitz.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. slay πŸ’œ


and that's the whole page, bestie!! it came from perl v5.30.3 and it's dated 2020-08-31, so yeah, this page is a lil vintage but it still serves ✨ go forth and attribute your methods, you absolute legend πŸŽ€πŸ’–πŸ¦‹

πŸ“¦ where this page comes from