Skip Menu |

This queue is for tickets about the Moose-Autobox CPAN distribution.

Report information
The Basics
Id: 34315
Status: resolved
Priority: 0/
Queue: Moose-Autobox

People
Owner: stevan.little [...] gmail.com
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.06
Fixed in: (no value)



Subject: Doesn't work on non-ref scalars.
$ perl -Mautobox -wle 'sub SCALAR::bar { 42 } $thing = 23; print $thing->bar' 42 $ perl -MMoose::Autobox -wle 'sub SCALAR::bar { 42 } $thing = 23; print $thing->bar' Can't call method "bar" without a package or object reference at -e line 1. While this does potentially conflict with class method calls, calling methods on simple scalars is really handy. $string->strip_ws, for example.
I guess I can't just define a method in SCALAR like in autobox, I have to mixin a role. The docs aren't very clear about that.
Moose::Autobox intentionally uses the Moose::Autobox::* namespace for its SCALAR, HASH, ARRAY, CODE extensions. This is to avoid clashes with other autobox modules. Your code would work written like: perl -MMoose::Autobox -wle 'sub Moose::Autobox::SCALAR::bar { 42 } $thing = 23; $thing- Show quoted text
>print'
This will be documented in the next release of Moose::Autobox to be more clear. You can also use the 'mixin_additional_role' role feature, as shown in the examples/units/ directory. - Stevan