Hello,
following Moose::Cookbook::Extending::Recipe4, I would like to create MyMoose,
so instead of
use Moose;
use MooseX::SemiAffordanceAccessor;
I can write just
use MyMoose;
in all my classes. I have more than 400 such classes and the real MyMoose
should also do other useful stuff, so it actually should save more than one
line. However, I have problems even with this minimal example:
## File MyMoose.pm
package MyMoose;
use Moose;
use Moose::Exporter;
#use Moose::Util::MetaRole; # I saw this somewhere, but it didn't help
use MooseX::SemiAffordanceAccessor::Role::Attribute;
Moose::Exporter->setup_import_methods(
also => 'Moose',
class_metaroles => {attribute =>
['MooseX::SemiAffordanceAccessor::Role::Attribute']},
);
1;
## File Try.pm
package Try;
#use Moose; #<--- This should not be needed
use MyMoose;
has 'my_attr' => (is=>'rw');
for (map {$_->fully_qualified_name} __PACKAGE__->meta->get_all_methods ) {
print "$_\n" if /my_attr/;
}
1;
## From command line
$ perl -MTry -e1
Try::my_attr
# after uncommenting "use Moose" in Try.pm
$ perl -MTry -e1
Try::my_attr
Try::set_my_attr
So it seems that MyMoose can substitute Moose XOR
MooseX::SemiAffordanceAccessor.
Is this a bug or a (strange) feature?
Is this related to https://rt.cpan.org/Public/Bug/Display.html?id=51561 ?
This is not critical, since I can just add "use Moose; use MyMoose;" to all my
classes, but it makes me think Moose is a black magic I will never understand.
Thanks for your answers
Martin Popel