has 'bar' => (
traits => [ qw(MooseX::UndefTolerant::Attribute)],
is => 'ro',
isa => 'Num',
predicate => 'has_bar'
# Meanwhile, under the city...
# Doesn't explode
my $class = My::Class->new(bar => undef);
$class->has_bar # False!
DESCRIPTIONApplying this trait to your attribute makes it's initialization tolerant of of undef. If you specify the value of undef to any of the attributes they will not be initialized (or will be set to the default, if applicable). Effectively behaving as if you had not provided a value at all.
AUTHORCory G Watson <gphat at cpan.org>
COPYRIGHT AND LICENCEThis software is copyright (c) 2011 by Cory G Watson.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.