File Coverage

blib/lib/Protocol/Redis/XS.pm
Criterion Covered Total %
statement 26 26 100.0
branch 3 4 75.0
condition 2 3 66.6
subroutine 8 8 100.0
pod 3 3 100.0
total 42 44 95.4


line stmt bran cond sub pod time code
1             package Protocol::Redis::XS;
2 2     2   333345 use strict;
  2         2  
  2         60  
3 2     2   6 use warnings;
  2         3  
  2         107  
4 2     2   352 use parent "Protocol::Redis";
  2         300  
  2         13  
5              
6 2     2   6981 use XS::Object::Magic;
  2         1212  
  2         76  
7 2     2   13 use XSLoader;
  2         2  
  2         376  
8              
9             our $VERSION = '0.10';
10              
11             XSLoader::load "Protocol::Redis::XS", $VERSION;
12              
13             sub new {
14 3     3 1 144095 my($class, %args) = @_;
15              
16 3         9 my $on_message = delete $args{on_message};
17              
18             Carp::croak(qq/Unknown Protocol::Redis API version $args{api}/)
19 3 100 66     235 unless defined $args{api} and $args{api} == 1;
20              
21 2         6 my $self = bless \%args, $class;
22 2 50       8 $self->on_message($on_message) if defined $on_message;
23              
24 2         19 $self->_create;
25              
26 2         8 return $self;
27             }
28              
29             # See Protocol::Redis for description of the API versioning
30             sub api {
31 1     1 1 761 my($self) = @_;
32              
33 1         7 $self->{api};
34             }
35              
36             sub on_message {
37 5     5 1 1619 my($self, $cb) = @_;
38 5         22 $self->{_on_message_cb} = $cb;
39             }
40              
41             1;
42              
43             __END__