This is an automated email from the git hooks/post-receive script.

gregoa pushed a commit to annotated tag release-0.001
in repository libclass-tiny-perl.

commit bdbc12c62c2b962279d7d2ba66bb5743d622f1d7
Author: David Golden <dagol...@cpan.org>
Date:   Fri Aug 16 09:19:06 2013 -0400

    tidy up code
---
 lib/Class/Tiny.pm | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib/Class/Tiny.pm b/lib/Class/Tiny.pm
index ceb6556..a3ddb3c 100644
--- a/lib/Class/Tiny.pm
+++ b/lib/Class/Tiny.pm
@@ -38,11 +38,13 @@ sub import {
 
 sub new {
     my $class = shift;
+
+    # handle hash ref or key/value arguments
     my $args;
-    if ( @_ == 1 && ref $_[0] ) { # hope it's a hash or hash object
-        my %copy = eval { %{ $_[0] } }; # shallow copy
+    if ( @_ == 1 && ref $_[0] ) {
+        my %copy = eval { %{ $_[0] } }; # try shallow copy
         if ($@) {
-            Carp::croak("Argument to $class->new() could not be dereferenced 
as a hash");
+            Carp::croak( "Argument to $class->new() could not be dereferenced 
as a hash" );
         }
         $args = \%copy;
     }
@@ -52,6 +54,8 @@ sub new {
     else {
         Carp::croak("$class->new() got an odd number of elements");
     }
+
+    # unknown attributes are fatal
     my @bad;
     my @search = @{ mro::get_linear_isa($class) };
     for my $k ( keys %$args ) {
@@ -61,12 +65,15 @@ sub new {
     if (@bad) {
         Carp::croak("Invalid attributes for $class: @bad");
     }
+
+    # create object and invoke BUILD
     my $self = bless $args, $class;
     for my $s ( reverse @search ) {
         no strict 'refs';
         my $builder = *{ $s . "::BUILD" }{CODE};
         $self->$builder if defined $builder;
     }
+
     return $self;
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/libclass-tiny-perl.git

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to