X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FTypes%2FData%2FGUID.pm;fp=lib%2FMooseX%2FTypes%2FData%2FGUID.pm;h=d36cf5607cf8d41d7c3a06b7842c23473a667da8;hb=63491692f764fd78c57a148ad6354d8e99bad264;hp=0000000000000000000000000000000000000000;hpb=a719a1f95dcae9777e7807c17914ee79596c16c2;p=gitmo%2FMooseX-Types-Data-GUID.git diff --git a/lib/MooseX/Types/Data/GUID.pm b/lib/MooseX/Types/Data/GUID.pm new file mode 100644 index 0000000..d36cf56 --- /dev/null +++ b/lib/MooseX/Types/Data/GUID.pm @@ -0,0 +1,68 @@ +package MooseX::Types::Data::GUID; + +use strict; +use warnings; + +use Data::GUID; +use MooseX::Types -declare => [qw/ GUID /]; +use Moose::Util::TypeConstraints; + +class_type 'Data::GUID'; +subtype GUID, as 'Data::GUID'; + +coerce 'Data::GUID' => + from Str => via { Data::GUID->from_any_string($_) }; + +coerce GUID, + from Str => via { Data::GUID->from_any_string($_) }; + +1; + +__END__; + +=head1 NAME + +MooseX::Types::Data::GUID - L related constraints and coercions for +Moose + +=head1 SYNOPSIS + +Export Example: + + use MooseX::Types::Data::GUID qw(TimeZone); + + has guid => ( + isa => GUID, + is => "rw", + coerce => 1, + ); + + Class->new( guid => "C6A9FE9A-72FE-11DD-B3B4-B2EC1DADD46B"); + +Namespaced Example: + + use MooseX::Types::Data::GUID; + + has guid => ( + isa => 'Data::GUID', + is => "rw", + coerce => 1, + ); + + Class->new( guid => "C6A9FE9A-72FE-11DD-B3B4-B2EC1DADD46B"); + +=head1 DESCRIPTION + +This module packages several L with coercions, +designed to work with L. + +=head1 AUTHOR + +Guillermo Roditi (groditi) Egroditi@cpan.orgE + +=head1 COPYRIGHT + +Copyright (c) 2008 Guillermo Roditi. This program is free software; you can +redistribute it and/or modify it under the same terms as Perl itself. + +=cut