File Coverage

blib/lib/AnyEvent/JSONRPC/CondVar.pm
Criterion Covered Total %
statement 9 13 69.2
branch n/a
condition n/a
subroutine 3 5 60.0
pod 2 2 100.0
total 14 20 70.0


line stmt bran cond sub pod time code
1             package AnyEvent::JSONRPC::CondVar;
2 1     1   6 use Any::Moose;
  1         2  
  1         8  
3              
4 1     1   548 use AnyEvent;
  1         2  
  1         83  
5              
6             has cv => (
7             is => 'ro',
8             isa => 'AnyEvent::CondVar',
9             default => sub {
10             AnyEvent->condvar;
11             },
12             handles => [qw( send recv cb )],
13             );
14              
15             has call => (
16             is => 'ro',
17             isa => 'JSON::RPC::Common::Procedure::Call',
18             required => 1,
19             handles => [qw( is_notification )],
20             );
21              
22 1     1   4 no Any::Moose;
  1         2  
  1         4  
23              
24             sub result {
25 0     0 1   my ($self, @result) = @_;
26 0           $self->send( $self->call->return_result( @result ));
27             }
28              
29             sub error {
30 0     0 1   my ($self, @error) = @_;
31 0           $self->send( $self->call->return_error ( @error ) );
32             }
33              
34             __PACKAGE__->meta->make_immutable;
35              
36             __END__
37              
38             =for stopwords condvar
39              
40             =head1 NAME
41              
42             AnyEvent::JSONRPC::CondVar - Condvar object used in
43             AnyEvent::JSONRPC::TCP::Server and AnyEvent::JSONRPC::HTTP::Server
44              
45             =head1 SEE ALSO
46              
47             L<AnyEvent::JSONRPC::TCP::Server> and L<AnyEvent::JSONRPC::HTTP::Server>
48              
49             =head1 METHOD
50              
51             =head2 result (@results)
52              
53             Return back C<@results> to client as result.
54              
55             =head2 error ($error)
56              
57             Return back C<$error> to client as error.
58              
59             =head1 AUTHOR
60              
61             Daisuke Murase <typester@cpan.org>
62              
63             =head1 COPYRIGHT AND LICENSE
64              
65             Copyright (c) 2009 by KAYAC Inc.
66              
67             This program is free software; you can redistribute
68             it and/or modify it under the same terms as Perl itself.
69              
70             The full text of the license can be found in the
71             LICENSE file included with this module.
72              
73             =cut