X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMoo.git;a=blobdiff_plain;f=lib%2FMoo.pm;h=fdd46e214ab91c0cabb495fc84b39ec471279faf;hp=02cb23c592e2eb565587faf7b8fdd7bec83a72d3;hb=141b507ace5957c098c52ceb7afaf21d5928a02d;hpb=6276fb9312263c60b54502204e856170c3772fe6 diff --git a/lib/Moo.pm b/lib/Moo.pm index 02cb23c..fdd46e2 100644 --- a/lib/Moo.pm +++ b/lib/Moo.pm @@ -5,7 +5,7 @@ use Moo::_Utils; use B 'perlstring'; use Sub::Defer (); -our $VERSION = '1.000002'; # 1.0.2 +our $VERSION = '1.000005'; # 1.0.5 $VERSION = eval $VERSION; require Moo::sification; @@ -35,12 +35,18 @@ sub import { $class->_maybe_reset_handlemoose($target); }; _install_tracked $target => has => sub { - my ($name, %spec) = @_; - $class->_constructor_maker_for($target) - ->register_attribute_specs($name, \%spec); - $class->_accessor_maker_for($target) - ->generate_method($target, $name, \%spec); - $class->_maybe_reset_handlemoose($target); + my ($name_proto, %spec) = @_; + my $name_isref = ref $name_proto eq 'ARRAY'; + foreach my $name ($name_isref ? @$name_proto : $name_proto) { + # Note that when $name_proto is an arrayref, each attribute + # needs a separate \%specs hashref + my $spec_ref = $name_isref ? +{%spec} : \%spec; + $class->_constructor_maker_for($target) + ->register_attribute_specs($name, $spec_ref); + $class->_accessor_maker_for($target) + ->generate_method($target, $name, $spec_ref); + $class->_maybe_reset_handlemoose($target); + } return; }; foreach my $type (qw(before after around)) { @@ -69,11 +75,11 @@ sub unimport { sub _set_superclasses { my $class = shift; my $target = shift; - for (@_) { - _load_module($_); - if ($INC{"Role/Tiny.pm"} && $Role::Tiny::INFO{$_}) { + foreach my $superclass (@_) { + _load_module($superclass); + if ($INC{"Role/Tiny.pm"} && $Role::Tiny::INFO{$superclass}) { require Carp; - Carp::croak("Can't extend role '$_'"); + Carp::croak("Can't extend role '$superclass'"); } } # Can't do *{...} = \@_ or 5.10.0's mro.pm stops seeing @ISA @@ -234,10 +240,10 @@ thirds of L. Unlike L this module does not aim at full compatibility with L's surface syntax, preferring instead of provide full interoperability -via the metaclass inflation capabilites described in L. +via the metaclass inflation capabilities described in L. For a full list of the minor differences between L and L's surface -syntax, see L. +syntax, see L. =head1 WHY MOO EXISTS @@ -790,6 +796,8 @@ Mithaldu - Christian Walde (cpan:MITHALDU) ilmari - Dagfinn Ilmari Mannsåker (cpan:ILMARI) +tobyink - Toby Inkster (cpan:TOBYINK) + =head1 COPYRIGHT Copyright (c) 2010-2011 the Moo L and L