X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FAttribute.pm;h=0265e1d27609e482f6e514d80b548260bca704ad;hb=3645b3164ce4e4fafa8ee65c515281175da0efe7;hp=c086b407faebd3f1e9bde4e814ab6dafbb0541ca;hpb=8473108059ddb46644a679a32f6e9bae8d9fd73c;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Attribute.pm b/lib/Mouse/Attribute.pm index c086b40..0265e1d 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} } @@ -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) { @@ -120,11 +120,12 @@ sub generate_clearer { sub generate_handles { my $attribute = shift; my $reader = $attribute->name; + my %handles = $attribute->_canonicalize_handles($attribute->handles); my %method_map; - for my $local_method (keys %{ $attribute->handles }) { - my $remote_method = $attribute->handles->{$local_method}; + for my $local_method (keys %handles) { + my $remote_method = $handles{$local_method}; my $method = 'sub { my $self = shift; @@ -147,9 +148,6 @@ sub create { if ref($args{default}) && ref($args{default}) ne 'CODE'; - $args{handles} = { $self->_canonicalize_handles($args{handles}) } - if $args{handles}; - $args{type_constraint} = delete $args{isa} if exists $args{isa}; @@ -271,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