Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Using Moose and BUILDARGS, but having trouble

by tobyink (Canon)
on Nov 30, 2018 at 00:07 UTC ( #1226518=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1226518]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2022-01-28 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (73 votes). Check out past polls.

    Notices?