1package AnyEvent::Gearman::Types;
2use Any::Moose;
3use Any::Moose '::Util::TypeConstraints';
4
5subtype 'AnyEvent::Gearman::Client::Connections'
6    => as 'ArrayRef[AnyEvent::Gearman::Client::Connection]';
7
8subtype 'AnyEvent::Gearman::Client::StrConnections'
9    => as 'ArrayRef[Str]';
10
11coerce 'AnyEvent::Gearman::Client::Connections'
12    => from 'AnyEvent::Gearman::Client::StrConnections' => via {
13        for my $con (@$_) {
14            next if ref($con) and $con->isa('AnyEvent::Gearman::Client::Connection');
15            $con = AnyEvent::Gearman::Client::Connection->new( hostspec => $con );
16        }
17        $_;
18    };
19
20subtype 'AnyEvent::Gearman::Worker::Connections'
21    => as 'ArrayRef[AnyEvent::Gearman::Worker::Connection]';
22
23subtype 'AnyEvent::Gearman::Worker::StrConnections'
24    => as 'ArrayRef[Str]';
25
26coerce 'AnyEvent::Gearman::Worker::Connections'
27    => from 'AnyEvent::Gearman::Worker::StrConnections' => via {
28        for my $con (@$_) {
29            next if ref($con) and $con->isa('AnyEvent::Gearman::Worker::Connection');
30            $con = AnyEvent::Gearman::Worker::Connection->new( hostspec => $con );
31        }
32        $_;
33    };
34
351;
36
37__END__
38
39=head1 NAME
40
41AnyEvent::Gearman::Types - some subtype definitions
42
43=head1 AUTHOR
44
45Daisuke Murase <typester@cpan.org>
46
47Pedro Melo <melo@cpan.org>
48
49=head1 COPYRIGHT AND LICENSE
50
51Copyright (c) 2009 by KAYAC Inc.
52
53This program is free software; you can redistribute
54it and/or modify it under the same terms as Perl itself.
55
56The full text of the license can be found in the
57LICENSE file included with this module.
58
59=cut
60