---
name: "UR::Role::Prototype"
section: "3pm"
platform: "linux"
package: "libur-perl"
version: "0.470+ds-3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/UR::Role::Prototype"
---

# UR::Role::Prototype(3pm)

Implementation for defining and composing roles

## NAME

UR::Role::Prototype - Implementation for defining and composing roles

## DESCRIPTION

Basic info about using roles is described in the documentation for UR::Role.

When a role is defined using the `"role"` keyword, it creates a UR::Role::Prototype instance.  Role prototypes represent an uncomposed role.  They have most of the same properties as UR::Object::Type instances.

### Methods

- property\_data($property\_name)

  Returns a hashref of property data about the named property.

- **has\_property\_names()**

  Returns a list of all the properties named in the role's `"has"`.

- **id\_by\_property\_names()**

  Returns a list of all the properties named in the roles's `"id_by"`.

- **method\_names()**

  Returns a list of all the function names in the role's namespace.

- define(%role\_definition)

  Define a role and return the role prototype.

- **role\_name()**

  Return the name of the role.

- **class\_names()**

  Returns a list of the names of the classes composing this role.

- **requires()**

  Returns an arrayref of strings.  These strings must exist in composing classes, either as properties or methods.

- **excludes()**

  Returns an arrayref of role names that may not be composed with this role.

### Role namespace methods

When a role is defined, these methods are injected into the role's namespace

- create(%params)

  Return a UR::Role::PrototypeWithParams object representing this role with a set of params immediately before it is composed into a class.  See the section on Parameterized Roles in UR::Role.

- \_\_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.

## SEE ALSO

UR, UR::Object::Type::Initializer, UR::Role::Instance, UR::Role::PrototypeWithParams
