X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FAttribute.pm;h=7d3c3805ad4fdab790e06ea0eb849b76e57a2fed;hb=f3c1ccc818bb5c50c50e17b9141b91c09b077b04;hp=115af444f3b2934323a879ab99f562dae4259b95;hpb=c3cc36426995c03e0b44d087c6d0cf3f2a3ceb69;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Attribute.pm b/lib/Mouse/Attribute.pm index 115af44..7d3c380 100644 --- a/lib/Mouse/Attribute.pm +++ b/lib/Mouse/Attribute.pm @@ -26,7 +26,7 @@ sub is_lazy { $_[0]->{lazy} } sub predicate { $_[0]->{predicate} } sub clearer { $_[0]->{clearer} } sub handles { $_[0]->{handles} } -sub weak_ref { $_[0]->{weak_ref} } +sub is_weak_ref { $_[0]->{weak_ref} } sub init_arg { $_[0]->{init_arg} } sub type_constraint { $_[0]->{type_constraint} } sub trigger { $_[0]->{trigger} } @@ -44,7 +44,7 @@ sub generate_accessor { my $attribute = shift; my $name = $attribute->name; - my $key = $attribute->init_arg; + my $key = $name; my $default = $attribute->default; my $trigger = $attribute->trigger; my $type = $attribute->type_constraint; @@ -67,8 +67,8 @@ sub generate_accessor { $accessor .= '$self->{$key} = $_;'; - if ($attribute->weak_ref) { - $accessor .= 'Scalar::Util::weaken($self->{$key});'; + if ($attribute->is_weak_ref) { + $accessor .= 'Scalar::Util::weaken($self->{$key}) if ref($self->{$key});'; } if ($trigger) { @@ -101,7 +101,7 @@ sub generate_accessor { sub generate_predicate { my $attribute = shift; - my $key = $attribute->init_arg; + my $key = $attribute->name; my $predicate = 'sub { exists($_[0]->{$key}) }'; @@ -110,7 +110,7 @@ sub generate_predicate { sub generate_clearer { my $attribute = shift; - my $key = $attribute->init_arg; + my $key = $attribute->name; my $predicate = 'sub { delete($_[0]->{$key}) }'; @@ -269,7 +269,7 @@ installed. Some error checking is done. =head2 has_handles -> Bool -=head2 weak_ref -> Bool +=head2 is_weak_ref -> Bool =head2 init_arg -> Str