File Coverage

blib/lib/WebService/GrowthBook/Result.pm
Criterion Covered Total %
statement 25 39 64.1
branch n/a
condition n/a
subroutine 10 17 58.8
pod 0 13 0.0
total 35 69 50.7


line stmt bran cond sub pod time code
1             package WebService::GrowthBook::Result;
2              
3 4     4   208195 use strict;
  4         101  
  4         331  
4 4     4   60 use warnings;
  4         8  
  4         300  
5 4     4   622 no indirect;
  4         1584  
  4         29  
6 4     4   1060 use Object::Pad;
  4         13619  
  4         26  
7              
8             our $VERSION = '0.003'; ## VERSION
9              
10             class WebService::GrowthBook::Result{
11 0     0 0 0 field $variation_id :param :reader;
  0         0  
12 82     82 0 353 field $in_experiment :param :reader;
  82         421  
13 78     78 0 491 field $value :param :reader;
  78         456  
14 70     70 0 344 field $hash_used :param :reader;
  70         370  
15 0     0 0 0 field $hash_attribute :param :reader;
  0         0  
16 0     0 0 0 field $hash_value :param :reader;
  0         0  
17 0     0 0 0 field $feature_id :param :reader;
  0         0  
18             field $bucket :param :reader //= undef;
19 7     7 0 13 field $sticky_bucket_used :param :reader //= undef;
  7         24  
20 0     0 0 0 field $meta :param //= undef;
  0         0  
21             field $key :reader //= undef;
22              
23 0     0 0 0 field $name :reader //= "";
  0     0 0 0  
  0         0  
24 0     17 0 0 field $passthrough :reader //= 0;;
  17         31  
  17         55  
25              
26             sub BUILDARGS {
27 82     82 0 214 my $class = shift;
28 82         649 my %args = @_;
29 82         1485 return %args;
30             }
31              
32             ADJUST {
33             $key = defined($variation_id) ? "$variation_id" : undef;
34             $name = $meta->{name} if exists $meta->{name};
35             $key = $meta->{key} if exists $meta->{key};
36             $passthrough = $meta->{passthrough} if exists $meta->{passthrough};
37             }
38              
39             method to_hash {
40             my %obj = (
41             featureId => $feature_id,
42             variationId => $variation_id,
43             inExperiment => $in_experiment,
44             value => $value,
45             hashUsed => $hash_used,
46             hashAttribute => $hash_attribute,
47             hashValue => $hash_value,
48             key => $key,
49             );
50              
51             $obj{stickyBucketUsed} = $sticky_bucket_used if $sticky_bucket_used;
52             $obj{bucket} = $self->bucket if defined $bucket;
53             $obj{name} = $name if $name;
54             $obj{passthrough} = 1 if $self->passthrough;
55              
56             return \%obj;
57             }
58              
59              
60             }
61              
62             1;