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