File Coverage

blib/lib/AnyEvent/ZeroMQ/Reply.pm
Criterion Covered Total %
statement 2 4 50.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 4 6 66.6


line stmt bran cond sub pod time code
1             package AnyEvent::ZeroMQ::Reply;
2             BEGIN {
3 1     1   2243 $AnyEvent::ZeroMQ::Reply::VERSION = '0.01';
4             }
5             # ABSTRACT: Non-blocking OO abstraction over ZMQ_REP request/reply sockets
6 1     1   813 use Moose;
  0            
  0            
7             use true;
8             use namespace::autoclean;
9             use Scalar::Util qw(weaken);
10             use ZeroMQ::Raw::Constants qw(ZMQ_REP);
11              
12             with 'AnyEvent::ZeroMQ::Role::WithHandle' =>
13             { socket_type => ZMQ_REP, socket_direction => '' };
14              
15             has 'on_request' => (
16             is => 'ro',
17             isa => 'CodeRef',
18             required => 1,
19             );
20              
21             after 'BUILD' => sub {
22             my $self = shift;
23             my $h = $self->handle;
24              
25             weaken $self;
26             $h->on_read(sub {
27             my ($h, $msg) = @_;
28             my $res = $self->on_request->($self, $msg);
29             $h->push_write($res);
30             });
31             };
32              
33             with 'AnyEvent::ZeroMQ::Handle::Role::Generic';
34              
35             __PACKAGE__->meta->make_immutable;
36              
37             __END__
38             =pod
39              
40             =head1 NAME
41              
42             AnyEvent::ZeroMQ::Reply - Non-blocking OO abstraction over ZMQ_REP request/reply sockets
43              
44             =head1 VERSION
45              
46             version 0.01
47              
48             =head1 AUTHOR
49              
50             Jonathan Rockway <jrockway@cpan.org>
51              
52             =head1 COPYRIGHT AND LICENSE
53              
54             This software is copyright (c) 2011 by Jonathan Rockway.
55              
56             This is free software; you can redistribute it and/or modify it under
57             the same terms as the Perl 5 programming language system itself.
58              
59             =cut
60