develooper Front page | perl.moose | Postings from June 2011

Re: defining my own parameterized types

Thread Previous | Thread Next
From:
John Napiorkowski
Date:
June 24, 2011 06:01
Subject:
Re: defining my own parameterized types
Message ID:
1308920510.33660.YahooMailNeo@web30404.mail.mud.yahoo.com
>________________________________
>From: Mark Wood-Patrick <mwoodpatrick@gmail.com>
>To: moose@perl.org
>Sent: Friday, June 24, 2011 8:51 AM
>Subject: defining my own parameterized types
>
>
>I would like to add my own parameterized type e.g. I would like to be able to create types like:
> 
>            SzStr[32]

I wrote http://search.cpan.org/perldoc?MooseX::Types::Parameterizable as a sort of exercise for this, would love for people to give it a go and let me know how it works out.


> 
>Which would allow me to specify the maximum size of a string that an attribute can have and will validate the size of the data I’m storing in the attribute
> 
>Or to specify that an attribute is a secondary key in some DB like:
> 
>            DBKey[User]

http://search.cpan.org/dist/MooseX-Attribute-Dependent/ also seems interesting, not sure if either the above exactly fit the bill.


> 
>Where User is a Moose class that provides an in memory version of a DB record and the attribute would be a weak reference to such an object
> 
>Is this currently possible? I looked at the docs for things like:
> 
>    http://search.cpan.org/dist/Moose/lib/Moose/Meta/TypeConstraint/Parameterized.pm
> 
>but that has:
> 
>METHODS 
>This class is intentionally not documented because the API is confusing and needs some work.
> 
>I would appreciate any pointers to examples or docs
>Thanks in advance
>Mark Wood-Patrick
>  
>
>
>
>
>
> 
> 
> 
>
>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About