UR::Ro...ototype(3pm)

πŸ“¦
version 0.470 Β· 2 versions
, in debian bookworm, ubuntu jammy, ubuntu noble

✨ 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's has. All of them. Every single one. πŸ’–
  • id_by_property_names() β€” Returns a list of all the properties named in the roles's id_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 a UR::Role::PrototypeWithParams object representing this role with a set of params immediately before it is composed into a class. Peep the section on Parameterized Roles in UR::Role for the full lore. πŸ“
  • __role__() β€” Calls the above create() 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:

  • UR
  • UR::Object::Type::Initializer
  • UR::Role::Instance
  • UR::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