http://qs321.pair.com?node_id=1226518


in reply to Using Moose and BUILDARGS, but having trouble

Use coercion in your attributes in Funky::Rectangle.

package Funky::Rectangle; use Moose; use Types::Standard qw(InstanceOf Str); use Data::Dump 'pp'; my $vertex_type = InstanceOf->of('Funky::Vertex')->plus_constructors(S +tr, "new"); has 'LL' => (is=>'rw', isa=>$vertex_type, coerce=>1); has 'UR' => (is=>'rw', isa=>$vertex_type, coerce=>1); # ...

Update: note that this can be achieved using Moose's built-in type constraints, but adding coercions to those has a global effect which can result in spooky action at a distance.