package Me::Trait::M; use Moose::Role; has mything => ( isa => 'Maybe[Bool]', is => 'rw', default => 0 ); after 'install_accessors' => sub { my $self = shift; my $realclass = $self->associated_class(); my $closure = $self->name; my $coderef = sub { my $self = shift; print $self->$closure()."\n"; }; $realclass->add_method( 'print_' . $closure => $coderef ); }; no Moose::Role;