File Coverage

blib/lib/Redis/hiredis.pm
Criterion Covered Total %
statement 12 19 63.1
branch 3 8 37.5
condition n/a
subroutine 3 5 60.0
pod 1 1 100.0
total 19 33 57.5


line stmt bran cond sub pod time code
1             package Redis::hiredis;
2              
3 9     9   8377 use strict;
  9         21  
  9         2683  
4             our $VERSION = "0.11.0";
5             require XSLoader;
6             XSLoader::load('Redis::hiredis', $VERSION);
7              
8             our $AUTOLOAD;
9              
10             sub new {
11 9     9 1 6508 my($class, %args) = @_;
12              
13 9 50       52 if(!exists $args{utf8}) {
14 9         29 $args{utf8} = 1;
15             }
16              
17 9         64 my $self = $class->_new($args{utf8});
18              
19 9 50       58 if(exists $args{host}) {
    50          
20 0 0       0 $self->connect($args{host}, defined $args{port} ? $args{port} : 6379);
21             }
22             elsif (exists $args{path}) {
23 0         0 $self->connect_unix($args{path});
24             }
25              
26 9         36 return $self;
27             }
28              
29             sub AUTOLOAD {
30 0     0     (my $method = $AUTOLOAD) =~ s/.*:://;
31              
32             # cache method for future calls
33 0     0     my $sub = sub { shift->command($method, @_) };
  0            
34 9     9   54 no strict 'refs';
  9         25  
  9         544  
35 0           *$AUTOLOAD = $sub;
36              
37 0           goto $sub;
38             }
39              
40             1;
41             __END__