From: Hans Dieter Pearcey Date: Wed, 8 Jul 2009 15:11:19 +0000 (-0400) Subject: Merge branch 'master' into attribute_helpers X-Git-Tag: 0.89_02~96 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6f94c802188d44415bafdd64422cecd24585a289;p=gitmo%2FMoose.git Merge branch 'master' into attribute_helpers Conflicts: Changes lib/Moose/Meta/Method/Delegation.pm t/020_attributes/010_attribute_delegation.t --- 6f94c802188d44415bafdd64422cecd24585a289 diff --cc Changes index ced07dc,e11a9e2..7a5fb8f --- a/Changes +++ b/Changes @@@ -1,15 -1,20 +1,29 @@@ Also see Moose::Manual::Delta for more details of, and workarounds for, noteworthy changes. - ++0.88 + * Moose::Meta::Attribute + - Added the currying syntax for delegation from AttributeHelpers + to the existing delegation API. (hdp) + + * Moose::AttributeHelpers + - Moved in from MooseX with API tweaks. See Moose::Manual::Delta for + details. (hdp, jhannah, rbuels) + + 0.87 Tue Jul 7, 2009 + * Moose::Meta::Method::Delegation + - Once again allow class names as well as objects for + delegation. This was changed in 0.86. + + 0.86 Fri Jul 3, 2009 + * Moose::Meta::Class::Immutable::Trait + - Fixes to work with the latest Class::MOP. + + * Moose::Meta::Method::Delegation + - Delegation now dies with a more useful error message if the + attribute's accessor returns something defined but + unblessed. (hdp) + 0.85 Fri, Jun 26, 2009 * Moose::Meta::Attribute - The warning for 'no associated methods' is now split out into diff --cc lib/Moose/Meta/Method/Delegation.pm index 910beb4,870d362..f353161 --- a/lib/Moose/Meta/Method/Delegation.pm +++ b/lib/Moose/Meta/Method/Delegation.pm @@@ -88,17 -79,24 +88,24 @@@ sub _initialize_body $self->{body} = sub { my $instance = shift; my $proxy = $instance->$accessor(); - ( defined $proxy ) - || $self->throw_error( - "Cannot delegate $handle_name to $method_to_call because " - . "the value of " - . $self->associated_attribute->name - . " is not defined", - method_name => $method_to_call, - object => $instance + + my $error + = !defined $proxy ? ' is not defined' + : ref($proxy) && !blessed($proxy) ? qq{ is not an object (got '$proxy')} + : undef; + + if ($error) { + $self->throw_error( + "Cannot delegate $handle_name to $method_to_call because " + . "the value of " + . $self->associated_attribute->name + . $error, + method_name => $method_to_call, + object => $instance ); + } - - $proxy->$method_to_call(@_); + my @args = (@{ $self->curried_arguments }, @_); + $proxy->$method_to_call(@args); }; } diff --cc t/020_attributes/010_attribute_delegation.t index 7e44c45,a47d7a7..e3a5f0a --- a/t/020_attributes/010_attribute_delegation.t +++ b/t/020_attributes/010_attribute_delegation.t @@@ -3,7 -3,7 +3,7 @@@ use strict; use warnings; - use Test::More tests => 89; -use Test::More tests => 91; ++use Test::More tests => 92; use Test::Exception; @@@ -27,10 -29,7 +29,11 @@@ has 'foo' => ( is => 'rw', default => sub { Foo->new }, - handles => { 'foo_bar' => 'bar', foo_baz => 'baz' } + handles => { + 'foo_bar' => 'bar', ++ foo_baz => 'baz', + 'foo_bar_to_20' => [ bar => [ 20 ] ], - } ++ }, ); }