Revision history for MooseX-UndefTolerant
+0.02 December 2, 2009
+ * Actually check the value properly, therefore setting it properly
+
0.01 Date/time
First version, released on an unsuspecting world.
package MooseX::UndefTolerant::Attribute;
use Moose::Role;
-around('initialize_instance_slot', sub{
+around('initialize_instance_slot', sub {
my $orig = shift;
my $self = shift;
- # If the parameter passed in was undef, quietly do nothing but return
- return unless defined($_->[2]);
+ my $ia = $self->init_arg;
+
+ # $_[2] is the hashref of options passed to the constructor. If our
+ # parameter passed in was undef, quietly do nothing but return.
+ return unless exists($_[2]->{$ia}) && defined($_[2]->{$ia});
# If it was defined, call the real init slot method
$self->$orig(@_)
ok(!$foo->has_bar);
}
+{
+ my $foo = Foo2->new(bar => 1234);
+ cmp_ok($foo->bar, 'eq', 1234);
+ ok($foo->has_bar);
+}
-done_testing;
\ No newline at end of file
+done_testing;