File Coverage

blib/lib/Bread/Board/Service/Alias.pm
Criterion Covered Total %
statement 15 15 100.0
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod n/a
total 22 23 95.6


line stmt bran cond sub pod time code
1             package Bread::Board::Service::Alias;
2             our $AUTHORITY = 'cpan:STEVAN';
3             # ABSTRACT: aliases another service
4             $Bread::Board::Service::Alias::VERSION = '0.37';
5 53     53   400 use Moose;
  53         126  
  53         520  
6              
7 53     53   343923 use Try::Tiny;
  53         149  
  53         12856  
8              
9             has aliased_from_path => (
10             is => 'ro',
11             isa => 'Str',
12             );
13              
14             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             with 'Bread::Board::Service';
23              
24             sub _build_aliased_from {
25 24     24   47 my $self = shift;
26              
27 24         597 my $path = $self->aliased_from_path;
28 24 50       58 confess "Can't create an alias service without a service to alias from"
29             unless $path;
30              
31             return try {
32 24     24   938 $self->fetch($path);
33             }
34             catch {
35 1     1   482 die "While resolving alias " . $self->name . ": $_";
36 24         157 };
37             }
38              
39             __PACKAGE__->meta->make_immutable;
40              
41 53     53   453 no Moose; 1;
  53         150  
  53         337  
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.37
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) 2019, 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