If there are a lot of methods (e.g. accessors) in a class that are required in a role and those need to be set over and over when creating a test
role-object, one needs to repeat foo => sub { "foo" } a lot. To make that less tedious, it will now check if the thing assigned to a method name
is a scalar (not a ref) and in that case wrap it in an anonymous sub. That makes it similar to what Moose does when declaring a scalar as a default value for an attribute.
It will still break when you assign something other than a coderef or a scalar, e.g. a hashref.
If there are a lot of methods (e.g. accessors) in a class that are required in a role and those need to be set over and over when creating a test role-object, one needs to repeat
foo => sub { "foo" }
a lot. To make that less tedious, it will now check if the thing assigned to a method name is a scalar (not a ref) and in that case wrap it in an anonymous sub. That makes it similar to what Moose does when declaring a scalar as a default value for an attribute.It will still break when you assign something other than a coderef or a scalar, e.g. a hashref.