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

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

commit 03a96040a8fdf1a8b15c491667ce463b2cd646e5
Author: Toby Inkster <m...@tobyinkster.co.uk>
Date:   Mon Aug 19 22:38:00 2013 +0100

    DWIM on `use Class::Tiny "foo"; use Class::Tiny "bar"`
---
 lib/Class/Tiny.pm |  5 ++---
 t/foxtrot.t       | 19 +++++++++++++++++++
 t/lib/Foxtrot.pm  | 10 ++++++++++
 3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/lib/Class/Tiny.pm b/lib/Class/Tiny.pm
index 9b26f07..cf79a29 100644
--- a/lib/Class/Tiny.pm
+++ b/lib/Class/Tiny.pm
@@ -27,12 +27,11 @@ sub import {
         defined and !ref and /^[^\W\d]\w*$/s
           or Carp::croak "Invalid accessor name '$_'"
     } @_;
-    $CLASS_ATTRIBUTES{$pkg} = { map { $_ => undef } @attr };
-    my $child = !!@{"${pkg}::ISA"};
+    $CLASS_ATTRIBUTES{$pkg}{$_} = undef for @attr;
+    @{"${pkg}::ISA"} = $class unless @{"${pkg}::ISA"};
     #<<< No perltidy
     eval join "\n", ## no critic: intentionally eval'ing subs here
       "package $pkg;",
-      ( $child ? () : "\@${pkg}::ISA = 'Class::Tiny';" ),
       map {
         "sub $_ { return \@_ == 1 ? \$_[0]->{$_} : (\$_[0]->{$_} = \$_[1]) }\n"
       } grep { ! *{"$pkg\::$_"}{CODE} } @attr;
diff --git a/t/foxtrot.t b/t/foxtrot.t
new file mode 100644
index 0000000..286cf5b
--- /dev/null
+++ b/t/foxtrot.t
@@ -0,0 +1,19 @@
+use 5.008001;
+use strict;
+use warnings;
+use lib 't/lib';
+
+use Test::More 0.96;
+use TestUtils;
+
+require_ok("Foxtrot");
+
+subtest "attribute set as list" => sub {
+    my $obj = new_ok( "Foxtrot", [ foo => 42, bar => 23 ] );
+    is( $obj->foo, 42, "foo is set" );
+    is( $obj->bar, 23, "bar is set" );
+};
+
+done_testing;
+# COPYRIGHT
+# vim: ts=4 sts=4 sw=4 et:
diff --git a/t/lib/Foxtrot.pm b/t/lib/Foxtrot.pm
new file mode 100644
index 0000000..4d79a8c
--- /dev/null
+++ b/t/lib/Foxtrot.pm
@@ -0,0 +1,10 @@
+use 5.008001;
+use strict;
+use warnings;
+
+package Foxtrot;
+
+use Class::Tiny 'foo';
+use Class::Tiny 'bar';
+
+1;

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