Skip to content

Commit

Permalink
Minor simplification.
Browse files Browse the repository at this point in the history
  • Loading branch information
rafl committed Jul 31, 2009
1 parent d983389 commit 483483b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/MooseX/Role/WithOverloading/Meta/Role/Application.pm
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 483483b

Please sign in to comment.