+ - remove multi-populate code to fix exists/defined new() bug
- document move to #moose and include repository metadata
- no Moo and no Moo::Role
- squelch used only once warnings for $Moo::HandleMoose::MOUSE
}
}
-sub generate_multi_set {
- my ($self, $me, $to_set, $from) = @_;
- "\@{${me}}{qw(${\join ' ', @$to_set})} = $from";
-}
-
sub _generate_core_set {
my ($self, $me, $name, $spec, $value) = @_;
my $name_str = perlstring $name;
sub _assign_new {
my ($self, $spec) = @_;
- my (@init, @slots, %test);
my $ag = $self->accessor_generator;
+ my %test;
NAME: foreach my $name (sort keys %$spec) {
my $attr_spec = $spec->{$name};
- unless ($ag->is_simple_attribute($name, $attr_spec)) {
- next NAME unless defined($attr_spec->{init_arg})
- or $ag->has_eager_default($name, $attr_spec);
- $test{$name} = $attr_spec->{init_arg};
- next NAME;
- }
- next NAME unless defined(my $i = $attr_spec->{init_arg});
- push @init, $i;
- push @slots, $name;
+ next NAME unless defined($attr_spec->{init_arg})
+ or $ag->has_eager_default($name, $attr_spec);
+ $test{$name} = $attr_spec->{init_arg};
}
- return '' unless @init or %test;
- join '', (
- @init
- ? ' '.$self->_cap_call($ag->generate_multi_set(
- '$new', [ @slots ], '@{$args}{qw('.join(' ',@init).')}', $spec
- )).";\n"
- : ''
- ), map {
+ join '', map {
my $arg_key = perlstring($test{$_});
my $test = "exists \$args->{$arg_key}";
my $source = "\$args->{$arg_key}";
--- /dev/null
+use Test::More tests => 1;
+
+package Foo;
+use Moo;
+
+has this => (is => 'ro');
+
+package main;
+
+my $foo = Foo->new;
+
+ok not(exists($foo->{this})),
+ "new objects don't have undef attributes";