| 1 | package MooseX::APIRole::Meta; | ||||||||||
| 2 | 1 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | $MooseX::APIRole::Meta::VERSION = '0.01'; | |||||||||
| 4 | } | ||||||||||
| 5 | # ABSTRACT: metarole for classes and roles that have API roles | ||||||||||
| 6 | 1 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use true; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | use MooseX::APIRole::Internals qw(create_role_for); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | has 'api_role_name' => ( | |||||||||
| 14 | reader => 'api_role_name', | ||||||||||
| 15 | writer => 'set_api_role_name', | ||||||||||
| 16 | predicate => 'has_api_role_name', | ||||||||||
| 17 | lazy => 1, | ||||||||||
| 18 | builder => '_build_api_role_name', | ||||||||||
| 19 | ); | ||||||||||
| 20 | |||||||||||
| 21 | 0 | ▶ | sub _build_api_role_name { | ||||||||
|
Subroutine
_build_api_role_name: not called CC=1 SCAR=6.9
| |||||||||||
| 22 | 0 | my ($self) = @_; | |||||||||
| 23 | 0 | return $self->api_role->name; | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 1 | has 'api_role' => ( | |||||||||
| 27 | reader => 'get_api_role', | ||||||||||
| 28 | predicate => 'has_api_role', | ||||||||||
| 29 | lazy => 1, | ||||||||||
| 30 | builder => '_build_api_role', | ||||||||||
| 31 | ); | ||||||||||
| 32 | |||||||||||
| 33 | 5 | ▶ | sub api_role { goto($_[0]->can('get_api_role')) } | ||||||||
|
Subroutine
api_role: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 34 | |||||||||||
| 35 | 4 | ▶ | sub _build_api_role { | ||||||||
|
Subroutine
_build_api_role: called CC=2 SCAR=7.0
| |||||||||||
| 36 | 4 | my ($self) = @_; | |||||||||
| 37 | 4 | my $has_name = $self->has_api_role_name; | |||||||||
| 38 | 4 | ▶ | my $role = $has_name ? create_role_for($self, $self->api_role_name) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | : create_role_for($self); | ||||||||||
| 40 | 4 | return $role; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | |||||||||||
| 44 | |||||||||||
| 45 | =pod | ||||||||||
| 46 | |||||||||||
| 47 | =head1 NAME | ||||||||||
| 48 | |||||||||||
| 49 | MooseX::APIRole::Meta - metarole for classes and roles that have API roles | ||||||||||
| 50 | |||||||||||
| 51 | =head1 VERSION | ||||||||||
| 52 | |||||||||||
| 53 | version 0.01 | ||||||||||
| 54 | |||||||||||
| 55 | =head1 ATTRIBUTES | ||||||||||
| 56 | |||||||||||
| 57 | =head2 api_role_name | ||||||||||
| 58 | |||||||||||
| 59 | The name of the API role. If you set this before the API role is | ||||||||||
| 60 | lazily built, then this will be the package that the role is installed | ||||||||||
| 61 | into. | ||||||||||
| 62 | |||||||||||
| 63 | =head3 get_api_role_name | ||||||||||
| 64 | |||||||||||
| 65 | =head3 set_api_role_name | ||||||||||
| 66 | |||||||||||
| 67 | =head3 has_api_role_name | ||||||||||
| 68 | |||||||||||
| 69 | =head2 api_role | ||||||||||
| 70 | |||||||||||
| 71 | The API role. Built when needed, usually by L<MooseX::APIRole>'s | ||||||||||
| 72 | C<make_api_role> method. | ||||||||||
| 73 | |||||||||||
| 74 | =head3 get_api_role | ||||||||||
| 75 | |||||||||||
| 76 | =head3 api_role | ||||||||||
| 77 | |||||||||||
| 78 | api_role is an alias for get_api_role. | ||||||||||
| 79 | |||||||||||
| 80 | =head3 has_api_role | ||||||||||
| 81 | |||||||||||
| 82 | =head1 AUTHOR | ||||||||||
| 83 | |||||||||||
| 84 | Jonathan Rockway <jrockway@cpan.org> | ||||||||||
| 85 | |||||||||||
| 86 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 87 | |||||||||||
| 88 | This software is copyright (c) 2010 by Jonathan Rockway. | ||||||||||
| 89 | |||||||||||
| 90 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 91 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 92 | |||||||||||
| 93 | =cut | ||||||||||
| 94 | |||||||||||
| 95 | |||||||||||
| 96 | __END__ | ||||||||||