AnyEvent::Gearman::Types - some subtype definitions


AnyEvent-Gearman documentation Contained in the AnyEvent-Gearman distribution.

Index


Code Index:

NAME

Top

AnyEvent::Gearman::Types - some subtype definitions

AUTHOR

Top

Daisuke Murase <typester@cpan.org>

Pedro Melo <melo@cpan.org>

COPYRIGHT AND LICENSE

Top


AnyEvent-Gearman documentation Contained in the AnyEvent-Gearman distribution.

package AnyEvent::Gearman::Types;
use Any::Moose;
use Any::Moose '::Util::TypeConstraints';

subtype 'AnyEvent::Gearman::Client::Connections'
    => as 'ArrayRef[AnyEvent::Gearman::Client::Connection]';

subtype 'AnyEvent::Gearman::Client::StrConnections'
    => as 'ArrayRef[Str]';

coerce 'AnyEvent::Gearman::Client::Connections'
    => from 'AnyEvent::Gearman::Client::StrConnections' => via {
        for my $con (@$_) {
            next if ref($con) and $con->isa('AnyEvent::Gearman::Client::Connection');
            $con = AnyEvent::Gearman::Client::Connection->new( hostspec => $con );
        }
        $_;
    };

subtype 'AnyEvent::Gearman::Worker::Connections'
    => as 'ArrayRef[AnyEvent::Gearman::Worker::Connection]';

subtype 'AnyEvent::Gearman::Worker::StrConnections'
    => as 'ArrayRef[Str]';

coerce 'AnyEvent::Gearman::Worker::Connections'
    => from 'AnyEvent::Gearman::Worker::StrConnections' => via {
        for my $con (@$_) {
            next if ref($con) and $con->isa('AnyEvent::Gearman::Worker::Connection');
            $con = AnyEvent::Gearman::Worker::Connection->new( hostspec => $con );
        }
        $_;
    };

1;

__END__