* replace two more eval { } calls with try { } (doy)
+ * Moose::Meta::Method::Delegation
+ - preserve aliasing for delegated methods (doy)
+
0.92 Tue, Sep 22, 2009
* Moose::Util::TypeConstraints
- added the match_on_type operator (Stevan)
sub _make_delegation_method {
my ( $self, $handle_name, $method_to_call ) = @_;
- my $method_body;
-
- $method_body = $method_to_call
- if 'CODE' eq ref($method_to_call);
-
my @curried_arguments;
($method_to_call, @curried_arguments) = @$method_to_call
object => $instance
);
}
- my @args = (@{ $self->curried_arguments }, @_);
- $proxy->$method_to_call(@args);
+ unshift @_, @{ $self->curried_arguments };
+ $proxy->$method_to_call(@_);
};
}
--- /dev/null
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 3;
+
+{
+ package Foo;
+ use Moose;
+
+ sub aliased {
+ my $self = shift;
+ $_[1] = $_[0];
+ }
+}
+
+{
+ package HasFoo;
+ use Moose;
+
+ has foo => (
+ is => 'ro',
+ isa => 'Foo',
+ handles => {
+ foo_aliased => 'aliased',
+ foo_aliased_curried => ['aliased', 'bar'],
+ }
+ );
+}
+
+my $hasfoo = HasFoo->new(foo => Foo->new);
+my $x;
+$hasfoo->foo->aliased('foo', $x);
+is($x, 'foo', "direct aliasing works");
+undef $x;
+$hasfoo->foo_aliased('foo', $x);
+is($x, 'foo', "delegated aliasing works");
+undef $x;
+$hasfoo->foo_aliased_curried($x);
+is($x, 'bar', "delegated aliasing with currying works");