File Coverage

blib/lib/Consul/Session.pm
Criterion Covered Total %
statement 15 18 83.3
branch 0 12 0.0
condition n/a
subroutine 5 7 71.4
pod 0 1 0.0
total 20 38 52.6


line stmt bran cond sub pod time code
1             package Consul::Session;
2             $Consul::Session::VERSION = '0.025';
3 9     9   71 use namespace::autoclean;
  9         21  
  9         64  
4              
5 9     9   870 use Moo;
  9         24  
  9         50  
6 9     9   3366 use Types::Standard qw(Str ArrayRef Enum);
  9         32  
  9         66  
7 9     9   7569 use Carp qw(croak);
  9         20  
  9         516  
8 9     9   57 use JSON::MaybeXS;
  9         23  
  9         2768  
9              
10             has name => ( is => 'ro', isa => Str );
11             has behavior => ( is => 'ro', isa => Enum[qw(release delete)] );
12             has ttl => ( is => 'ro', isa => Str );
13             has node => ( is => 'ro', isa => Str );
14             has checks => ( is => 'ro', isa => ArrayRef[Str] );
15             has lock_delay => ( is => 'ro', isa => Str );
16              
17 0     0 0   sub to_json { shift->_json }
18             has _json => ( is => 'lazy', isa => Str );
19             sub _build__json {
20 0     0     my ($self) = @_;
21 0 0         encode_json({
    0          
    0          
    0          
    0          
    0          
22             defined $self->lock_delay ? ( LockDelay => $self->lock_delay ) : (),
23             defined $self->node ? ( Node => $self->node ) : (),
24             defined $self->name ? ( Name => $self->name ) : (),
25             defined $self->checks ? ( Checks => $self->checks ) : (),
26             defined $self->behavior ? ( Behavior => $self->behavior ) : (),
27             defined $self->ttl ? ( TTL => $self->ttl ) : (),
28             });
29             }
30              
31             1;