[libbread-board-perl] 47/66: Support inheriting services in parameterized containers
Jonas Smedegaard
js at alioth.debian.org
Sun Sep 29 21:23:38 UTC 2013
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository libbread-board-perl.
commit 16b7a622a571d16d18d4eaf68b4e745c130fe5e4
Author: Florian Ragwitz <rafl at debian.org>
Date: Wed Aug 14 18:50:23 2013 -0400
Support inheriting services in parameterized containers
---
lib/Bread/Board.pm | 3 ++-
t/152_sugar_service_inheritance.t | 14 ++++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/lib/Bread/Board.pm b/lib/Bread/Board.pm
index ac69204..673dd9c 100644
--- a/lib/Bread/Board.pm
+++ b/lib/Bread/Board.pm
@@ -161,7 +161,8 @@ sub service ($@) {
confess "Inheriting services isn't possible outside of the context of a container"
unless defined $CC;
- my $prototype_service = $CC->fetch($name);
+ my $container = ($CC->isa('Bread::Board::Container::Parameterized') ? $CC->container : $CC);
+ my $prototype_service = $container->fetch($name);
confess sprintf(
"Trying to inherit from service '%s', but found a %s",
diff --git a/t/152_sugar_service_inheritance.t b/t/152_sugar_service_inheritance.t
index 5a502e6..59d7a61 100644
--- a/t/152_sugar_service_inheritance.t
+++ b/t/152_sugar_service_inheritance.t
@@ -87,6 +87,20 @@ use Bread::Board;
}
}
+{
+ my $parameterized = container MyApp => ['Config'] => as {
+ service foo => (block => sub { 42 });
+ };
+
+ container $parameterized => as {
+ service '+foo' => (block => sub { 23 });
+ };
+
+ my $c = $parameterized->create(Config => container Config => as {});
+
+ is $c->resolve(service => 'foo'), 23;
+}
+
like exception {
service '+foo' => 42;
}, qr/^Service inheritance doesn't make sense for literal services/;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libbread-board-perl.git
More information about the Pkg-perl-cvs-commits
mailing list