UR::Ro...ototype(3pm)
β¨ UR::Role::Prototype β the manual page π
okay so bestie, this page lives in the User Contributed Perl Documentation section, and it's about UR::Role::Prototype β aka the whole entire implementation for defining and composing roles π
πΈ NAME πΈ
UR::Role::Prototype β literally the implementation for defining and composing roles, periodt π
π¦ DESCRIPTION π¦
So the basic deets on using roles? Those live in the documentation for UR::Role. Go read that first, bestie, no cap π
Here's the tea: when a role gets defined using the role keyword, it creates a UR::Role::Prototype instance. Role prototypes represent an uncomposed role. And the way they have, like, most of the same properties as UR::Object::Type instances? Iconic. Chef's kiss. π
π Methods π
okay these are the methods, let's go one by one, don't skip π«Ά
property_data($property_name)β Returns a hashref of property data about the named property. Just hand it a name, get the data back. Slay. β¨has_property_names()β Returns a list of all the properties named in the role'shas. All of them. Every single one. πid_by_property_names()β Returns a list of all the properties named in the roles'sid_by. (yes the original says "roles's", we don't fix it, we respect it π)method_names()β Returns a list of all the function names in the role's namespace. Vibe check on the whole namespace, fr fr. πdefine(%role_definition)β Define a role and return the role prototype. That's the whole gig. πrole_name()β Return the name of the role. Simple, clean, main character energy. πclass_names()β Returns a list of the names of the classes composing this role. The whole squad. πrequires()β Returns an arrayref of strings. These strings must exist in composing classes, either as properties or methods. Not optional, bestie, it's a requirement, hence the name πexcludes()β Returns an arrayref of role names that may not be composed with this role. It's giving "you can't sit with us" π
π§ Role namespace methods π§
so when a role is defined, these methods get injected into the role's namespace. injected!! like little gifts π
create(%params)β Return aUR::Role::PrototypeWithParamsobject representing this role with a set of params immediately before it is composed into a class. Peep the section on Parameterized Roles inUR::Rolefor the full lore. π__role__()β Calls the abovecreate()method with no arguments. This is used by the role composition mechanism to trigger autoloading the role's module when role names are given as strings in a class definition. Lowkey the secret sauce π₯
β SEE ALSO β
go read these next, bestie, iykyk:
URUR::Object::Type::InitializerUR::Role::InstanceUR::Role::PrototypeWithParams
and that's the whole page, we ate and left no crumbs πβ¨
shoutout to the source: this came from perl v5.32.1, dated 2022-01-17, filed under UR::Ro...ototype(3pm) in the User Contributed Perl Documentation. mwah, bye bestie π«Άπ
π¦ where this page comes from
- debian bookworm: libur-perl 0.470+ds-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libur-perl 0.470+ds-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libur-perl 0.470+ds-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms