init_arg can be undef
[gitmo/Moose.git] / lib / Moose / Meta / Class.pm
index 928cd18..be298e7 100644 (file)
@@ -80,12 +80,11 @@ sub new_object {
     my ($class, %params) = @_;
     my $self = $class->SUPER::new_object(%params);
     foreach my $attr ($class->compute_all_applicable_attributes()) {
-        # FIXME:
-        # this does not accept undefined
-        # values, nor does it accept false
-        # values to be passed into the init-arg
-        next unless $params{$attr->init_arg} && $attr->can('has_trigger') && $attr->has_trigger;
-        $attr->trigger->($self, $params{$attr->init_arg}, $attr);
+        if ( defined( my $init_arg = $attr->init_arg ) ) {
+            if ( exists($params{$init_arg}) && $attr->can('has_trigger') && $attr->has_trigger ) {
+                $attr->trigger->($self, $params{$init_arg}, $attr);
+            }
+        }
     }
     return $self;
 }