[libbread-board-perl] 41/66: Allow the "container $obj" sugar for parameterized containers

Jonas Smedegaard js at alioth.debian.org
Sun Sep 29 21:23:37 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 75011a146248e0a959d82bb63ae88e4a47eb6c97
Author: Florian Ragwitz <rafl at debian.org>
Date:   Tue Aug 6 11:12:43 2013 -0400

    Allow the "container $obj" sugar for parameterized containers
---
 lib/Bread/Board.pm |    4 ++--
 t/301_sugar.t      |   22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/lib/Bread/Board.pm b/lib/Bread/Board.pm
index 8b518b8..57ab366 100644
--- a/lib/Bread/Board.pm
+++ b/lib/Bread/Board.pm
@@ -48,8 +48,8 @@ sub container ($;$$) {
 
     my $name_is_obj = 0;
     if (blessed $name){
-        confess 'an object used as a container must inherit from Bread::Board::Container'
-            unless $name->isa('Bread::Board::Container');
+        confess 'an object used as a container must inherit from Bread::Board::Container or Bread::Board::Container::Parameterized'
+            unless $name->isa('Bread::Board::Container') || $name->isa('Bread::Board::Container::Parameterized');
         $name_is_obj = 1;
     }
 
diff --git a/t/301_sugar.t b/t/301_sugar.t
index 73e53fd..ae4366b 100644
--- a/t/301_sugar.t
+++ b/t/301_sugar.t
@@ -59,4 +59,26 @@ $exception = exception{
 like( $exception, qr/isn't a service/, "exception contains: isn't a service" );
 
 
+{
+    my $parameterized_container = container 'Foo' => ['Bar'] => as {
+        service foo => (
+            block        => sub { shift->param('bar') },
+            dependencies => { bar => 'Bar/bar' },
+        );
+    };
+
+    is exception {
+        container $parameterized_container => as {
+            service moo => (
+                block        => sub { shift->param('foo') },
+                dependencies => [depends_on('foo')],
+            );
+        };
+    }, undef, 'contaner $parameterized_container => as {} succeeds';
+
+    is $parameterized_container->create(Bar => (container Bar => as {
+        service bar => 42;
+    }))->resolve(service => 'moo'), 42, 'container $parameterized_container => as {} modifies underlying container';
+}
+
 done_testing;

-- 
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