Bread-Board

 view release on metacpan or  search on metacpan

lib/Bread/Board/Service/Alias.pm  view on Meta::CPAN

package Bread::Board::Service::Alias;
our $AUTHORITY = 'cpan:STEVAN';
# ABSTRACT: aliases another service
$Bread::Board::Service::Alias::VERSION = '0.37';
use Moose;

use Try::Tiny;

has aliased_from_path => (
    is  => 'ro',
    isa => 'Str',
);

has aliased_from => (
    is      => 'ro',
    does    => 'Bread::Board::Service',
    lazy    => 1,
    builder => '_build_aliased_from',
    handles => ['get'], # is this sufficient?
);

with 'Bread::Board::Service';

sub _build_aliased_from {
    my $self = shift;

    my $path = $self->aliased_from_path;
    confess "Can't create an alias service without a service to alias from"
        unless $path;

    return try {
        $self->fetch($path);
    }
    catch {
        die "While resolving alias " . $self->name . ": $_";
    };
}

__PACKAGE__->meta->make_immutable;

no Moose; 1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Bread::Board::Service::Alias - aliases another service

=head1 VERSION

version 0.37

=head1 DESCRIPTION

This L<service|Bread::Board::Service> class implements
L<aliases|Bread::Board/alias ($service_name, $service_path,
%service_description)>.

=head1 ATTRIBUTES

=head2 C<aliased_from_path>

Read-only string attribute, the path of the service this alias refers



( run in 1.243 second using v1.01-cache-2.11-cpan-39bf76dae61 )