in reply to Moose composing role with required attribute into existing instance
Two possibilities occur to me.
One, compose the class and role together on the fly when you build the instance (instead of adding it to the instance after creation) so that when you need it you have it and when you don't you don't have to use it. This will allow your attribute to retain the required=>1 status. (This is my preference.)
use Moose::Util qw( with_traits );
my $point = with_traits(
x => 1,
y => 1,
name => 'my_point',
);#To satisfy the required values
If that doesn't seem to be a good fit then just add a default value and a setter (safer than 'rw') to your 'name' attribute. This will eliminate the error. You can then use your setter to change the value to the correct one when and where you want.
has 'name' => (
isa => 'Str',
is => 'ro',# Note the change
required => 1,
default => 'change_me',
writer => 'set_name',
TIMTOWTDI applies to Moose too!