| 1 | package Bread::Board::Service::WithClass; | ||||||||||
| 2 | 70 | our $AUTHORITY = 'cpan:STEVAN'; | |||||||||
| 3 | # ABSTRACT: role for services returning instances of a given class | ||||||||||
| 4 | 70 | $Bread::Board::Service::WithClass::VERSION = '0.36'; | |||||||||
| 5 | 70 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 70 | ▶ | use Module::Runtime (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 70 | ▶ | use Bread::Board::Types; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 70 | with 'Bread::Board::Service'; | |||||||||
| 11 | |||||||||||
| 12 | 70 | has 'class' => ( | |||||||||
| 13 | is => 'rw', | ||||||||||
| 14 | isa => 'Str', | ||||||||||
| 15 | predicate => 'has_class', | ||||||||||
| 16 | ); | ||||||||||
| 17 | |||||||||||
| 18 | before 'get' => sub { | ||||||||||
| 19 | 229 | ▶ | my $self = shift; | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 20 | 229 | ▶ | Module::Runtime::require_module($self->class) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | if $self->has_class; | ||||||||||
| 22 | 70 | }; | |||||||||
| 23 | |||||||||||
| 24 | 70 | ▶ | no Moose::Role; 1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | __END__ | ||||||||||
| 27 | |||||||||||
| 28 | =pod | ||||||||||
| 29 | |||||||||||
| 30 | =encoding UTF-8 | ||||||||||
| 31 | |||||||||||
| 32 | =head1 NAME | ||||||||||
| 33 | |||||||||||
| 34 | Bread::Board::Service::WithClass - role for services returning instances of a given class | ||||||||||
| 35 | |||||||||||
| 36 | =head1 VERSION | ||||||||||
| 37 | |||||||||||
| 38 | version 0.36 | ||||||||||
| 39 | |||||||||||
| 40 | =head1 DESCRIPTION | ||||||||||
| 41 | |||||||||||
| 42 | This a sub-role of L<Bread::Board::Service> for services that return | ||||||||||
| 43 | instances of a given class. | ||||||||||
| 44 | |||||||||||
| 45 | =head1 ATTRIBUTES | ||||||||||
| 46 | |||||||||||
| 47 | =head2 C<class> | ||||||||||
| 48 | |||||||||||
| 49 | Read/write string attribute, the name of the class that this service | ||||||||||
| 50 | will probably instantiate. | ||||||||||
| 51 | |||||||||||
| 52 | =head1 METHODS | ||||||||||
| 53 | |||||||||||
| 54 | =head2 C<has_class> | ||||||||||
| 55 | |||||||||||
| 56 | Predicate for the L</class> attribute, true if it has been set. | ||||||||||
| 57 | |||||||||||
| 58 | =head2 C<get> | ||||||||||
| 59 | |||||||||||
| 60 | This role adds a C<before> modifier to the C<get> method, ensuring | ||||||||||
| 61 | that the module implementing the L</class> is loaded. | ||||||||||
| 62 | |||||||||||
| 63 | =head1 AUTHOR | ||||||||||
| 64 | |||||||||||
| 65 | Stevan Little <stevan@iinteractive.com> | ||||||||||
| 66 | |||||||||||
| 67 | =head1 BUGS | ||||||||||
| 68 | |||||||||||
| 69 | Please report any bugs or feature requests on the bugtracker website | ||||||||||
| 70 | https://github.com/stevan/BreadBoard/issues | ||||||||||
| 71 | |||||||||||
| 72 | When submitting a bug or request, please include a test-file or a | ||||||||||
| 73 | patch to an existing test-file that illustrates the bug or desired | ||||||||||
| 74 | feature. | ||||||||||
| 75 | |||||||||||
| 76 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 77 | |||||||||||
| 78 | This software is copyright (c) 2017, 2016, 2015, 2014, 2013, 2011, 2009 by Infinity Interactive. | ||||||||||
| 79 | |||||||||||
| 80 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 81 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 82 | |||||||||||
| 83 | =cut | ||||||||||