has x => ( is => 'rw' ); around x => \&my_accessor;
I'd like to shorten that into
has x => ( is => 'rw', traits => ['MyAccessor']);
or even better, to
has x => ( isa => 'MyAccessor' );
possibly making MyAccessor a separate MooseX module. However, even with help of #moose I couldn't go far, and, also because IRC is not the best way of exchanging large pieces of code, I'd like to ask if you could help me here. I stopped here:
package Moose::Meta::Attribute::Custom::Trait::MyAccessor; sub register_implementation { return 'MyAccessor' } package MyAccessor; use Moose::Role; my $meta = __PACKAGE__->meta;
I thought that I should manipulate $meta, but I'm unsure how. Any ideas?
Thank you!
Update: as usual, I've asked how to do X when I wanted Y. My apologies. Actually, I'd like to use array and hash attributes in mixed list and array contexts:
@list = $obj-> prop; $obj->prop(@list); $array = $obj->prop; $obj->prop($array);
I though I could do that with "around", which prompted the original question
has prop; around prop => \&my_accessor;
Update #2: Problem solved. Proof of concept is on CPAN
In reply to Moose roles by dk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |