From: Matt S Trout Date: Tue, 29 Nov 2011 21:34:30 +0000 (+0000) Subject: only weaken when required X-Git-Tag: v0.001002~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=eca2edfe2e00b55ddabcfe2a8f2e219b1b623c5e;p=scpubgit%2FTak.git only weaken when required --- diff --git a/lib/Tak/MetaService.pm b/lib/Tak/MetaService.pm index 9706160..203f7af 100644 --- a/lib/Tak/MetaService.pm +++ b/lib/Tak/MetaService.pm @@ -1,6 +1,7 @@ package Tak::MetaService; use Tak::WeakClient; +use Log::Contextual qw(:log); use Moo; with 'Tak::Role::Service'; @@ -22,14 +23,21 @@ sub handle_register { my ($self, $name, $class, %args) = @_; (my $file = $class) =~ s/::/\//g; require "${file}.pm"; + my $router = $self->router; if (my $expose = delete $args{expose}) { - my $client = Tak::WeakClient->new(service => $self->router); - foreach my $name (%$expose) { - $args{$name} = $client->curry(@{$expose->{$name}}); + foreach my $name (keys %$expose) { + if (my ($svc, @rest) = @{$expose->{$name}}) { + die "router has no service ${svc}" + unless my $service = $router->services->{$svc}; + $args{$name} = Tak::Client->new(service => $service) + ->curry(@rest); + } else { + $args{$name} = Tak::WeakClient->new(service => $router); + } } } my $new = $class->new(\%args); - $self->router->register($name => $new); + $router->register($name => $new); return "Registered ${name}"; }