X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FMethod%2FDelegation.pm;h=a566a0a415bcd0c53daa350fdcf15629150c8311;hb=26f0aa174f72fdf5fd803278212b7cefa83c8734;hp=60bdad870b75dd23d9600b2d54bc36b6c713e61b;hpb=cb80a70a3d6101e0bc8f6576765a2d6c588d2ecd;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Meta/Method/Delegation.pm b/lib/Mouse/Meta/Method/Delegation.pm index 60bdad8..a566a0a 100644 --- a/lib/Mouse/Meta/Method/Delegation.pm +++ b/lib/Mouse/Meta/Method/Delegation.pm @@ -3,16 +3,21 @@ use Mouse::Util qw(:meta); # enables strict and warnings use Scalar::Util; sub _generate_delegation{ - my (undef, $attr, $handle_name, $method_to_call, @curried_args) = @_; + my (undef, $attr, $handle_name, $method_to_call) = @_; - my $reader = $attr->get_read_method_ref(); + my @curried_args; + if(ref($method_to_call) eq 'ARRAY'){ + ($method_to_call, @curried_args) = @{$method_to_call}; + } - my $can_be_optimized = $attr->{_method_delegation_can_be_optimized}; + # If it has a reader, we must use it to make method modifiers work + my $reader = $attr->get_read_method() || $attr->get_read_method_ref(); - if(!defined $can_be_optimized){ - my $tc = $attr->type_constraint; + my $can_be_optimized = $attr->{_mouse_cache_method_delegation_can_be_optimized}; - $attr->{_method_delegation_can_be_optimized} = + if(!defined $can_be_optimized){ + my $tc = $attr->type_constraint; + $attr->{_mouse_cache_method_delegation_can_be_optimized} = (defined($tc) && $tc->is_a_type_of('Object')) && ($attr->is_required || $attr->has_default || $attr->has_builder) && ($attr->is_lazy || !$attr->has_clearer); @@ -56,7 +61,7 @@ Mouse::Meta::Method::Delegation - A Mouse method generator for delegation method =head1 VERSION -This document describes Mouse version 0.50_02 +This document describes Mouse version 0.77 =head1 SEE ALSO