| 1 | package Bread::Board::Service::Alias; | ||||||||||
| 2 | 55 | our $AUTHORITY = 'cpan:STEVAN'; | |||||||||
| 3 | # ABSTRACT: aliases another service | ||||||||||
| 4 | 55 | $Bread::Board::Service::Alias::VERSION = '0.35'; | |||||||||
| 5 | 55 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 55 | ▶ | use Try::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 55 | has aliased_from_path => ( | |||||||||
| 10 | is => 'ro', | ||||||||||
| 11 | isa => 'Str', | ||||||||||
| 12 | ); | ||||||||||
| 13 | |||||||||||
| 14 | 55 | has aliased_from => ( | |||||||||
| 15 | is => 'ro', | ||||||||||
| 16 | does => 'Bread::Board::Service', | ||||||||||
| 17 | lazy => 1, | ||||||||||
| 18 | builder => '_build_aliased_from', | ||||||||||
| 19 | handles => ['get'], # is this sufficient? | ||||||||||
| 20 | ); | ||||||||||
| 21 | |||||||||||
| 22 | 55 | with 'Bread::Board::Service'; | |||||||||
| 23 | |||||||||||
| 24 | sub _build_aliased_from { | ||||||||||
| 25 | 24 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_build_aliased_from: called CC=2 SCAR=7.0
| |||||||||||
| 26 | |||||||||||
| 27 | 24 | my $path = $self->aliased_from_path; | |||||||||
| 28 | 24 | ▶ | confess "Can't create an alias service without a service to alias from" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | unless $path; | ||||||||||
| 30 | |||||||||||
| 31 | return try { | ||||||||||
| 32 | 24 | ▶ | $self->fetch($path); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 33 | } | ||||||||||
| 34 | catch { | ||||||||||
| 35 | 1 | ▶ | die "While resolving alias " . $self->name . ": $_"; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 36 | 24 | }; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 55 | __PACKAGE__->meta->make_immutable; | |||||||||
| 40 | |||||||||||
| 41 | 55 | ▶ | no Moose; 1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 42 | |||||||||||
| 43 | __END__ | ||||||||||
| 44 | |||||||||||
| 45 | =pod | ||||||||||
| 46 | |||||||||||
| 47 | =encoding UTF-8 | ||||||||||
| 48 | |||||||||||
| 49 | =head1 NAME | ||||||||||
| 50 | |||||||||||
| 51 | Bread::Board::Service::Alias - aliases another service | ||||||||||
| 52 | |||||||||||
| 53 | =head1 VERSION | ||||||||||
| 54 | |||||||||||
| 55 | version 0.35 | ||||||||||
| 56 | |||||||||||
| 57 | =head1 DESCRIPTION | ||||||||||
| 58 | |||||||||||
| 59 | This L<service|Bread::Board::Service> class implements | ||||||||||
| 60 | L<aliases|Bread::Board/alias ($service_name, $service_path, | ||||||||||
| 61 | %service_description)>. | ||||||||||
| 62 | |||||||||||
| 63 | =head1 ATTRIBUTES | ||||||||||
| 64 | |||||||||||
| 65 | =head2 C<aliased_from_path> | ||||||||||
| 66 | |||||||||||
| 67 | Read-only string attribute, the path of the service this alias refers | ||||||||||
| 68 | to (it can be an alias itself) | ||||||||||
| 69 | |||||||||||
| 70 | =head2 C<aliased_from> | ||||||||||
| 71 | |||||||||||
| 72 | Lazy read-only attribute, built by calling L<< | ||||||||||
| 73 | C<fetch>|Bread::Board::Traversable/fetch >> on this service using the | ||||||||||
| 74 | L</aliased_from_path> as path to fetch | ||||||||||
| 75 | |||||||||||
| 76 | =head1 AUTHOR | ||||||||||
| 77 | |||||||||||
| 78 | Stevan Little <stevan@iinteractive.com> | ||||||||||
| 79 | |||||||||||
| 80 | =head1 BUGS | ||||||||||
| 81 | |||||||||||
| 82 | Please report any bugs or feature requests on the bugtracker website | ||||||||||
| 83 | https://github.com/stevan/BreadBoard/issues | ||||||||||
| 84 | |||||||||||
| 85 | When submitting a bug or request, please include a test-file or a | ||||||||||
| 86 | patch to an existing test-file that illustrates the bug or desired | ||||||||||
| 87 | feature. | ||||||||||
| 88 | |||||||||||
| 89 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 90 | |||||||||||
| 91 | This software is copyright (c) 2017, 2016, 2015, 2014, 2013, 2011, 2009 by Infinity Interactive. | ||||||||||
| 92 | |||||||||||
| 93 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 94 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 95 | |||||||||||
| 96 | =cut | ||||||||||