X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FAttribute.pm;h=c30a9ee03d731dd62786fc63823729265c735797;hb=3fab876a432091471f0c7f8bf2c6c9eb0f289567;hp=5c87356b26b07de296c432bdc107050f9f0ca1c0;hpb=d7d8d49b322c4d0f274aaafb049b324e1de6b552;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 5c87356..c30a9ee 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -267,7 +267,13 @@ sub clone_and_inherit_options{ my($attribute_class, @traits) = ref($self)->interpolate_class(\%args); $args{traits} = \@traits if @traits; - return $attribute_class->new($self->name, %{$self}, %args); + # do not inherit the 'handles' attribute + foreach my $name(keys %{$self}){ + if(!exists $args{$name} && $name ne 'handles'){ + $args{$name} = $self->{$name}; + } + } + return $attribute_class->new($self->name, %args); } sub clone_parent { # DEPRECATED @@ -354,8 +360,8 @@ sub _canonicalize_handles { my $meta = Mouse::Meta::Class->initialize("$class_or_role"); # "" for stringify return map { $_ => $_ } - grep { $_ ne 'meta' && !Mouse::Object->can($_) && $_ =~ $handles } - Mouse::Util::TypeConstraints::_is_a_metarole($meta) + grep { !Mouse::Object->can($_) && $_ =~ $handles } + Mouse::Util::is_a_metarole($meta) ? $meta->get_method_list : $meta->get_all_method_names; } @@ -365,7 +371,7 @@ sub _canonicalize_handles { } sub associate_method{ - my ($attribute, $method) = @_; + my ($attribute, $method_name) = @_; $attribute->{associated_methods}++; return; } @@ -384,7 +390,7 @@ sub install_accessors{ my $generator = '_generate_' . $type; my $code = $accessor_class->$generator($attribute, $metaclass); $metaclass->add_method($attribute->{$type} => $code); - $attribute->associate_method($code); + $attribute->associate_method($attribute->{$type}); } } @@ -399,7 +405,7 @@ sub install_accessors{ $reader, $handle_name, $method_to_call); $metaclass->add_method($handle_name => $code); - $attribute->associate_method($code); + $attribute->associate_method($handle_name); } } @@ -429,7 +435,7 @@ Mouse::Meta::Attribute - The Mouse attribute metaclass =head1 VERSION -This document describes Mouse version 0.40_01 +This document describes Mouse version 0.40_06 =head1 METHODS @@ -537,12 +543,12 @@ is equivalent to this: =back -=head2 C<< associate_method(Method) >> +=head2 C<< associate_method(MethodName) >> Associates a method with the attribute. Typically, this is called internally when an attribute generates its accessors. -Currently the argument I is ignored in Mouse. +Currently the argument I is ignored in Mouse. =head2 C<< verify_against_type_constraint(Item) -> TRUE | ERROR >>