File Coverage

blib/lib/Job/Machine/Client.pm
Criterion Covered Total %
statement 9 26 34.6
branch n/a
condition 0 15 0.0
subroutine 3 7 42.8
pod 4 4 100.0
total 16 52 30.7


line stmt bran cond sub pod time code
1             package Job::Machine::Client;
2             $Job::Machine::Client::VERSION = '0.26';
3 1     1   572 use strict;
  1         2  
  1         23  
4 1     1   5 use warnings;
  1         2  
  1         29  
5              
6 1     1   4 use base 'Job::Machine::Base';
  1         2  
  1         267  
7              
8             sub send {
9 0     0 1   my ($self, $data, $queue) = @_;
10 0   0       $queue ||= $self->{queue};
11 0           my $id = $self->db->insert_task($data,$queue);
12 0           $self->{db}->notify(queue => $queue);
13 0           return $id;
14             }
15              
16             sub check {
17 0     0 1   my ($self, $id) = @_;
18 0   0       $id ||= $self->id;
19 0   0       $self->{subscribed} ||= $self->subscribe($id,1); # Subscribe if not already subscribed
20 0           return $self->db->get_notification;
21             }
22              
23             sub uncheck {
24 0     0 1   my ($self, $id) = @_;
25 0   0       $id ||= $self->id;
26 0           delete $self->{subscribed};
27 0           $self->db->unlisten(queue => $id, reply => 1);
28 0           return 1;
29             }
30              
31             sub receive {
32 0     0 1   my ($self, $id) = @_;
33 0   0       $id ||= $self->id;
34 0           return $self->db->fetch_first_result($id);
35             };
36              
37             1;
38              
39             __END__