Forget HandlesVia for now and consider this:
my @toppings = ( FishTaco::Topping->new ); my $ft = FishTaco->new( _toppings => \@toppings ); push @toppings, "OHAI";
You can push stuff onto the array without Moo checking that the stuff you're pushing makes any sense. This is because it only checks the array is valid in the constructor and in non-read-only attribute accessors. The exact same happens with Moose.
Moose native traits give you the handles stuff for arrays, and Moose is smart enough to add type checking to push when you do this. MooX::HandlesVia is not quite so smart. (This is partly due to limitations in how Moo works.)
Now try this:
my @toppings = ( FishTaco::Topping->new ); tie @toppings, InstanceOf['FishTaco::Topping']; my $ft = FishTaco->new( _toppings => \@toppings ); push @toppings, "OHAI"; # this should die
Yay?
Now play around with trigger.
In reply to Re: Trouble with, or misunderstanding of, Types::Standard ArrayRef[elements] enforcement in Moo
by tobyink
in thread Trouble with, or misunderstanding of, Types::Standard ArrayRef[elements] enforcement in Moo
by Your Mother
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |