From 483483b56a9cd10d730bd4f74ad5b23ac8c6bfdc Mon Sep 17 00:00:00 2001 From: Florian Ragwitz Date: Fri, 31 Jul 2009 09:22:18 +0200 Subject: [PATCH] Minor simplification. --- .../WithOverloading/Meta/Role/Application.pm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/MooseX/Role/WithOverloading/Meta/Role/Application.pm b/lib/MooseX/Role/WithOverloading/Meta/Role/Application.pm index a9ada18..a54bbb0 100644 --- a/lib/MooseX/Role/WithOverloading/Meta/Role/Application.pm +++ b/lib/MooseX/Role/WithOverloading/Meta/Role/Application.pm @@ -41,20 +41,20 @@ sub apply_overloading { my $meth = $role->get_package_symbol($code_sym); next unless $meth; - # use overload $op => 'method_name'; + # when using "use overload $op => sub { };" this is the actual method + # to be called on overloading. otherwise it's \&overload::nil. see + # below. + $other->add_package_symbol($code_sym => $meth); + + # when using "use overload $op => 'method_name';" overload::nil is + # installed into the code slot of the glob and the actual method called + # is determined by the scalar slot of the same glob. if ($meth == \&overload::nil) { my $scalar_sym = qq{\$($op}; - # overload::nil as the predicate for overloading with a method name - $other->add_package_symbol($code_sym => $meth); - # and the actual method name in the scalar slot of the same glob $other->add_package_symbol( $scalar_sym => ${ $role->get_package_symbol($scalar_sym) }, ); } - # use overload $op => sub { ... }; - else { - $other->add_package_symbol($code_sym => $meth); - } } }