X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FAttribute.pm;h=9fd883f47d58e1448afc3b9333dea982582d24f5;hp=77be3b44297d1c3334ed13c761264fd4a3c9d517;hb=065f79e7cd03765f26c6ea276aaf9b3c5897886a;hpb=745220df2da2256a9bd2692ac585f39b35ed19df diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 77be3b4..9fd883f 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -4,7 +4,9 @@ use Mouse::Util qw(:meta); # enables strict and warnings use Carp (); use Mouse::Meta::TypeConstraint; -use Mouse::Meta::Method::Accessor; + +#use Mouse::Meta::Method::Accessor; +use Mouse::Meta::Method::Delegation; sub _process_options{ @@ -265,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 @@ -368,6 +376,9 @@ sub associate_method{ return; } + +sub delegation_metaclass() { 'Mouse::Meta::Method::Delegation' } + sub install_accessors{ my($attribute) = @_; @@ -385,11 +396,12 @@ sub install_accessors{ # install delegation if(exists $attribute->{handles}){ + my $delegation_class = $attribute->delegation_metaclass; my %handles = $attribute->_canonicalize_handles($attribute->{handles}); my $reader = $attribute->get_read_method_ref; while(my($handle_name, $method_to_call) = each %handles){ - my $code = $accessor_class->_generate_delegation($attribute, $metaclass, + my $code = $delegation_class->_generate_delegation($attribute, $metaclass, $reader, $handle_name, $method_to_call); $metaclass->add_method($handle_name => $code); @@ -423,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_02 =head1 METHODS