[libbread-board-perl] 49/66: Simplify the container sugar

Jonas Smedegaard js at alioth.debian.org
Sun Sep 29 21:23:39 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 a265751c79b06970a80c69d0ca503ba22fad4a0a
Author: Florian Ragwitz <rafl at debian.org>
Date:   Wed Aug 28 13:30:35 2013 -0400

    Simplify the container sugar
---
 lib/Bread/Board.pm |   60 +++++++++++++++++-----------------------------------
 1 file changed, 19 insertions(+), 41 deletions(-)

diff --git a/lib/Bread/Board.pm b/lib/Bread/Board.pm
index 24a3f1d..16c97c9 100644
--- a/lib/Bread/Board.pm
+++ b/lib/Bread/Board.pm
@@ -44,7 +44,7 @@ sub set_root_container {
 }
 
 sub container ($;$$) {
-    my $name        = shift;
+    my $name = shift;
 
     my $name_is_obj = 0;
     if (blessed $name){
@@ -54,50 +54,28 @@ sub container ($;$$) {
     }
 
     my $c;
-    if ( scalar @_ == 0 ) {
-        if ( $name_is_obj ) {
-            # this is basically:
-            # container( A::Bread::Board::Container->new )
-            # which should work
-            $c = $name;
+    if ($name_is_obj) {
+        confess 'container($object, ...) is not supported for parameterized containers'
+            if scalar @_ > 1;
+        # this is basically:
+        # container( A::Bread::Board::Container->new, ... )
+        # or someone using &container as a constructor
+        $c = $name;
+    }
+    else {
+        # if we have more than 1 argument, then we are a parameterized
+        # container, so we need to act accordingly
+        if (scalar @_ > 1) {
+            my $param_names = shift;
+            $c = Bread::Board::Container::Parameterized->new({
+                name                    => $name,
+                allowed_parameter_names => $param_names,
+            });
         }
         else {
-            # otherwise it is just
-            # someone using &container
-            # as a constructor
-            $c = Bread::Board::Container->new(
-                name => $name
-            );
+            $c = Bread::Board::Container->new({ name => $name });
         }
     }
-    # if we have one more arg
-    # then we have block to
-    # follow us, that we want
-    # to use to create stuff
-    # with.
-    elsif ( scalar @_ == 1 ) {
-        $c = $name_is_obj
-            ? $name
-            : Bread::Board::Container->new( name => $name );
-    }
-    # if we have even more
-    # then we are a parameterized
-    # container, so we need to
-    # act accordingly
-    else {
-        confess 'container($object, ...) is not supported for parameterized containers'
-            if $name_is_obj;
-        my $param_names = shift;
-        $c = Bread::Board::Container::Parameterized->new(
-            name                    => $name,
-            allowed_parameter_names => $param_names,
-        )
-    }
-
-    # now, if we are here, then
-    # we obviously have something
-    # more to contribute to the
-    # container world ...
 
     # if we already have a root
     # container, then we are a

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