Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Minor simplification.

  • Loading branch information...
commit 483483b56a9cd10d730bd4f74ad5b23ac8c6bfdc 1 parent d983389
@rafl authored
Showing with 8 additions and 8 deletions.
  1. +8 −8 lib/MooseX/Role/WithOverloading/Meta/Role/Application.pm
View
16 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);
- }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.