title: Make the Moose constructor ignore undef arguments
body: <p>A hashtable is the typical initializer for your Perl objects. Now your input is unreliable in that you don't know whether for any given key there'll be a defined value, nor whether the key is there at all. Now you want to feed such unreliable input into Moose objects, and while absent keys are perfectly okay you do want to get rid of the undefined values so you don't end up with an object full of undefined attributes.</p>
  
  <p>You could certainly take great care when instantiating objects and filter out the undefined values. But let's say you want to install that filter in your constructor because then it is in one place. You want the constructor to ignore undefined values, but not to die on encountering them.</p>
  
  <p>For accessor methods, you can use <code>around</code> around to prevent the attribute to be set to <code>undef</code>. But those <a href="http://search.cpan.org/~drolsky/Moose-1.19/lib/Moose/Manual/MethodModifiers.pod" rel="nofollow">method modifiers</a> aren't called for the constructor, only for accessors. Is there a similar facility in Moose to achieve the same effect for the c'tor, i.e. to preclude any <code>undef</code> attributes from being accepted?</p>
  
  <p>Note that the Moose <code>Any</code> type will create the hash key in the object if the attribute is undef. I don't want that because I want <code>%$self</code> not to contain any <code>undef</code> values.</p>
  
  <p>Here's some testing I did:</p>
  
  <pre><code>package Gurke;
  use Moose;
  use Data::Dumper;
  
  has color  =&gt; is =&gt; 'rw', isa =&gt; 'Str', default =&gt; 'green';
  has length =&gt; is =&gt; 'rw', isa =&gt; 'Num';
  has appeal =&gt; is =&gt; 'rw', isa =&gt; 'Any';
  
  around color =&gt; sub {
      # print STDERR Dumper \@_;
      my $orig = shift;
      my $self = shift;
      return $self-&gt;$orig unless @_;
      return unless defined $_[0];
      return $self-&gt;$orig( @_ );
  };
  
  package main;
  use Test::More;
  use Test::Exception;
  
  my $gu = Gurke-&gt;new;
  isa_ok $gu, 'Gurke';
  diag explain $gu;
  ok ! exists $gu-&gt;{length}, 'attribute not passed, so not set';
  diag q(attempt to set color to undef - we don't want it to succeed);
  ok ! defined $gu-&gt;color( undef ), 'returns undef';
  is $gu-&gt;color, 'green', 'value unchanged';
  diag q(passing undef in the constructor will make it die);
  dies_ok { Gurke-&gt;new( color =&gt; undef ) }
      'around does not work for the constructor!';
  lives_ok { $gu = Gurke-&gt;new( appeal =&gt; undef ) } 'anything goes';
  diag explain $gu;
  diag q(... but creates the undef hash key, which is not what I want);
  done_testing;
  </code></pre>