| 1 | package UR::Role::Instance; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | our $VERSION = "0.46"; # UR $VERSION;; | ||
| 7 | |||
| 8 | UR::Object::Type->define( | ||
| 9 | class_name => 'UR::Role::Instance', | ||
| 10 | doc => 'Instance of a role composed into a class', | ||
| 11 | id_by => ['role_name','class_name'], | ||
| 12 | has => [ | ||
| 13 | role_name => { is => 'Text', doc => 'ID of the role prototype' }, | ||
| 14 | role_prototype => { is => 'UR::Role::Prototype', id_by => 'role_name' }, | ||
| 15 | class_name => { is => 'Test', doc => 'Class this role instance is composed into' }, | ||
| 16 | class_meta => { is => 'UR::Object::Type', id_by => 'class_name' }, | ||
| 17 | role_params => { is => 'HASH', doc => 'Parameters used when this role was composed', is_optional => 1 }, | ||
| 18 | ], | ||
| 19 | is_transactional => 0, | ||
| 20 | ); | ||
| 21 | |||
| 22 | 1; | ||
| 23 | |||
| 24 | =pod | ||
| 25 | |||
| 26 | =head1 NAME | ||
| 27 | |||
| 28 | UR::Role::Instance - Represents a role composed with a class with a set of params | ||
| 29 | |||
| 30 | =head1 DESCRIPTION | ||
| 31 | |||
| 32 | When a class composes one or more roles, the role names given in the class | ||
| 33 | description are converted to UR::Role::Instance objects as the class is | ||
| 34 | constructed. These are returned by the class' C<roles()> method. | ||
| 35 | |||
| 36 | =head2 Methods | ||
| 37 | |||
| 38 | =over 4 | ||
| 39 | |||
| 40 | =item role_name() | ||
| 41 | |||
| 42 | Returns the name of the role | ||
| 43 | |||
| 44 | =item class_name() | ||
| 45 | |||
| 46 | Returns the name of the class composing the role | ||
| 47 | |||
| 48 | =item role_params() | ||
| 49 | |||
| 50 | Returns a hashref of role params used when the class composed the role | ||
| 51 | |||
| 52 | =back | ||
| 53 | |||
| 54 | =head1 SEE ALSO | ||
| 55 | |||
| 56 | L<UR::Role>, L<UR::Role::Prototype> |