d36cf5607cf8d41d7c3a06b7842c23473a667da8
[gitmo/MooseX-Types-Data-GUID.git] / lib / MooseX / Types / Data / GUID.pm
1 package MooseX::Types::Data::GUID;
2
3 use strict;
4 use warnings;
5
6 use Data::GUID;
7 use MooseX::Types -declare => [qw/ GUID /];
8 use Moose::Util::TypeConstraints;
9
10 class_type 'Data::GUID';
11 subtype GUID, as 'Data::GUID';
12
13 coerce 'Data::GUID' =>
14   from Str => via { Data::GUID->from_any_string($_) };
15
16 coerce GUID,
17   from Str => via { Data::GUID->from_any_string($_) };
18
19 1;
20
21 __END__;
22
23 =head1 NAME
24
25 MooseX::Types::Data::GUID - L<Data::GUID> related constraints and coercions for
26 Moose
27
28 =head1 SYNOPSIS
29
30 Export Example:
31
32     use MooseX::Types::Data::GUID qw(TimeZone);
33
34     has guid => (
35         isa => GUID,
36         is => "rw",
37         coerce => 1,
38     );
39
40     Class->new( guid => "C6A9FE9A-72FE-11DD-B3B4-B2EC1DADD46B");
41
42 Namespaced Example:
43
44     use MooseX::Types::Data::GUID;
45
46     has guid => (
47         isa => 'Data::GUID',
48         is => "rw",
49         coerce => 1,
50     );
51
52     Class->new( guid => "C6A9FE9A-72FE-11DD-B3B4-B2EC1DADD46B");
53
54 =head1 DESCRIPTION
55
56 This module packages several L<Moose::Util::TypeConstraints> with coercions,
57 designed to work with L<Data::GUID>.
58
59 =head1 AUTHOR
60
61 Guillermo Roditi (groditi) E<lt>groditi@cpan.orgE<gt>
62
63 =head1 COPYRIGHT
64
65 Copyright (c) 2008 Guillermo Roditi. This program is free software; you can 
66 redistribute it and/or modify it under the same terms as Perl itself.
67
68 =cut