File Coverage

blib/lib/Protocol/Redis/XS.pm
Criterion Covered Total %
statement 26 26 100.0
branch 2 4 50.0
condition n/a
subroutine 8 8 100.0
pod 3 3 100.0
total 39 41 95.1


line stmt bran cond sub pod time code
1             package Protocol::Redis::XS;
2 2     2   136360 use strict;
  2         6  
  2         53  
3 2     2   10 use warnings;
  2         3  
  2         52  
4 2     2   752 use parent "Protocol::Redis";
  2         501  
  2         8  
5              
6 2     2   4234 use XS::Object::Magic;
  2         1066  
  2         53  
7 2     2   12 use XSLoader;
  2         2  
  2         298  
8              
9             our $VERSION = '0.06';
10              
11             XSLoader::load "Protocol::Redis::XS", $VERSION;
12              
13             sub new {
14 2     2 1 3033 my($class, %args) = @_;
15              
16 2         6 my $on_message = delete $args{on_message};
17              
18 2         5 my $self = bless \%args, $class;
19 2 50       6 return unless $self->api == 1;
20 2 50       21 $self->on_message($on_message) if defined $on_message;
21              
22 2         16 $self->_create;
23              
24 2         4 return $self;
25             }
26              
27             # See Protocol::Redis for description of the API versioning
28             sub api {
29 3     3 1 905 my($self) = @_;
30              
31 3         18 $self->{api};
32             }
33              
34             sub on_message {
35 5     5 1 996 my($self, $cb) = @_;
36 5         16 $self->{_on_message_cb} = $cb;
37             }
38              
39             1;
40              
41             __END__