If I want to change write protected attribute ie.
use Moops;
class foo {
has attr => (is => "rwp");
}
one have to use _set_attr()
.
Is it possible to change that to _attr()
without using explicit writer
?
Tried use MooseX::::AttributeShortcuts -writer_prefix => 'prefix';
but it did not work.
No, you need to do that yourself by setting the
writer
.TLDR: At the bottom is a monkey-patch to do it anyway.
The Moops docs say (emphasys mine):
Now let's go look at Moo. In the
has
section of the doc, it says (emphasys mine):Ok, on to MooseX::AttributeShortcuts:
However, this is just where it was inspired. It is actually implemented in Moo in Method::Generate::Accessor1.
And even more actually, that is also not where it is done in Moops. In fact, that happens in MooseX::MungeHas, which Moops uses, but only if the caller is not Moo:
Looks pretty clear. It's in generated code. The below solution might work if it uses only Moo, but I don't know how to force that.
You are indeed able to change that in Moo by hooking into Moo's Method::Generate::Accessor using Class::Method::Modifiers and adding a bit of logic in an
around
modifier togenerate_method
. Thisdoes not workworks for Moops as long as there is no Moose-stuff involved.Output:
1) I found that using grep.cpan.me.