, . - , , - . , "" Moose + A Custom Sugar, , Moose, :
package MySugar;
use strict;
use Moose::Exporter;
Moose::Exporter->setup_import_methods(
with_meta => [ 'has_rw' ],
as_is => [ 'thing' ],
also => 'Moose',
);
sub has_rw {
my ( $meta, $name, %options ) = @_;
$meta->add_attribute(
$name,
is => 'rw',
%options,
);
}
:
package MyApp;
use MySugar;
extends(Parent);
has_rw 'name';
has 'size';
thing;
MooseX::POE, . , extends , , , .
UPDATE: Parent , Moose:: Object.
package Parent::Methods;
use 5.10.0;
use Moose::Role;
sub something_special { say 'sparkles' }
Moose:: Exporter MySugar,
Moose::Exporter->setup_import_methods(
apply_base_class_roles => 'Parent::Methods',
with_meta => ['has_rw'],
as_is => ['thing'],
also => 'Moose',
);
package MyApp;
use MySugar;
has_rw 'name';
has 'size';
thing;
package main;
MyApp->new->something_special;
, .