use B 'perlstring';
use Sub::Defer ();
-our $VERSION = '1.000001'; # 1.0.1
+our $VERSION = '1.000004'; # 1.0.4
$VERSION = eval $VERSION;
require Moo::sification;
$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)) {
.' '.$class.'->_constructor_maker_for($class,'.perlstring($target).');'."\n"
.' return $class->new(@_)'.";\n"
.' } elsif ($INC{"Moose.pm"} and my $meta = Class::MOP::get_metaclass_by_name($class)) {'."\n"
- .' return $meta->new_object(@_);'."\n"
+ .' return $meta->new_object($class->BUILDARGS(@_));'."\n"
.' }'."\n"
),
)
Unlike L<Mouse> this module does not aim at full compatibility with
L<Moose>'s surface syntax, preferring instead of provide full interoperability
-via the metaclass inflation capabilites described in L</MOO AND MOOSE>.
+via the metaclass inflation capabilities described in L</MOO AND MOOSE>.
For a full list of the minor differences between L<Moose> and L<Moo>'s surface
syntax, see L</INCOMPATIBILITIES>.
use Sub::Quote;
has foo => (
- is => quote_sub(q{ die "Not <3" unless $_[0] < 3 })
+ is => 'ro',
+ isa => quote_sub(q{ die "Not <3" unless $_[0] < 3 })
);
which will be inlined as
or to avoid localizing @_,
has foo => (
- is => quote_sub(q{ my ($val) = @_; die "Not <3" unless $val < 3 })
+ is => 'ro',
+ isa => quote_sub(q{ my ($val) = @_; die "Not <3" unless $val < 3 })
);
which will be inlined as
ilmari - Dagfinn Ilmari Mannsåker (cpan:ILMARI) <ilmari@ilmari.org>
+tobyink - Toby Inkster (cpan:TOBYINK) <tobyink@cpan.org>
+
=head1 COPYRIGHT
Copyright (c) 2010-2011 the Moo L</AUTHOR> and L</CONTRIBUTORS>