Checking in changes prior to tagging of version 0.40_08. Changelog diff is:
[gitmo/Mouse.git] / lib / Mouse / Meta / Method / Delegation.pm
CommitLineData
d7d8d49b 1package Mouse::Meta::Method::Delegation;
2use Mouse::Util; # enables strict and warnings
3use Scalar::Util qw(blessed);
4
5sub _generate_delegation{
6 my (undef, $attribute, $metaclass, $reader, $handle_name, $method_to_call) = @_;
7
8 return sub {
9 my $instance = shift;
10 my $proxy = $instance->$reader();
11
12 my $error = !defined($proxy) ? ' is not defined'
13 : ref($proxy) && !blessed($proxy) ? qq{ is not an object (got '$proxy')}
14 : undef;
15 if ($error) {
16 $instance->meta->throw_error(
17 "Cannot delegate $handle_name to $method_to_call because "
18 . "the value of "
19 . $attribute->name
20 . $error
21 );
22 }
23 $proxy->$method_to_call(@_);
24 };
25}
26
27
281;
29__END__
30
31=head1 NAME
32
33Mouse::Meta::Method::Delegation - A Mouse method generator for delegation methods
34
35=head1 VERSION
36
f7e41eda 37This document describes Mouse version 0.40_08
d7d8d49b 38
39=head1 SEE ALSO
40
41L<Moose::Meta::Method::Delegation>
42
43=cut