File Coverage

blib/lib/WebService/GrowthBook/Experiment.pm
Criterion Covered Total %
statement 55 75 73.3
branch 0 12 0.0
condition n/a
subroutine 25 31 80.6
pod 0 27 0.0
total 80 145 55.1


line stmt bran cond sub pod time code
1             package WebService::GrowthBook::Experiment;
2              
3 4     4   154677 use strict;
  4         10  
  4         249  
4 4     4   27 use warnings;
  4         9  
  4         340  
5 4     4   341 use WebService::GrowthBook::Util qw(adjust_args_camel_to_snake);
  4         9  
  4         387  
6 4     4   1633 use Object::Pad;
  4         8440  
  4         32  
7              
8             our $VERSION = '0.003'; ## VERSION
9              
10             class WebService::GrowthBook::Experiment {
11 551     551 0 1129 field $key :param :reader;
  551         2076  
12 362     362 0 702 field $variations :param :reader //= [];
13 362     58 0 2609 field $weights :param :reader //= [];
  58         99  
14 58     75 0 247 field $active :param :reader //= 1;
  75         158  
15 75     128 0 371 field $status :param :reader //= "running";
  128         245  
16 128         675 field $coverage :param :reader //= undef;
17 65     65 0 153 field $condition :param :reader //= undef;
  65         163  
18 68     68 0 159 field $namespace :param :reader //= undef;
  68         281  
19 68     68 0 169 field $url :param :reader //= '';
  68     65 0 315  
  65         128  
20 65         256 field $include :param :reader //= undef;
21 66     66 0 149 field $groups :param :reader //= undef;
  66         239  
22 65     65 0 134 field $force :param :reader //= undef;
  65         307  
23 63     63 0 171 field $hash_attribute :param :reader //= 'id';
  63     156 0 245  
  156         315  
24 156         573 field $fallback_attribute :param :reader //= undef;
25 156     156 0 303 field $hash_version :param :reader //= 1;
  156     65 0 595  
  65         125  
26 65         398 field $ranges :param :reader //= undef;
27 65     65 0 158 field $meta :param :reader //= undef;
  65         269  
28 85     85 0 196 field $filters :param :reader //= undef;
  85         298  
29 73     73 0 187 field $seed :param :reader //= undef;
  73         357  
30 65     65 0 127 field $name :param :reader //= undef;
  65         982  
31 0     0 0 0 field $phase :param :reader //= undef;;
  0     0 0 0  
  0         0  
  0         0  
32 0     0 0 0 field $disable_sticky_bucketing :param :reader //= 0;
33 0     0 0 0 field $bucket_version :param :reader //= 0;
  0         0  
34 0     0 0 0 field $min_bucket_version :param :reader //= 0;
  0         0  
35 0         0 field $parent_conditions :param :reader //= undef;
36              
37 65     65 0 161 sub BUILDARGS {
  65         204  
38 90     90 0 1187 my ($class, %args) = @_;
39 90         377 adjust_args_camel_to_snake(\%args);
40 90         1777 return %args;
41             }
42              
43              
44 0     0 0   method update($data) {
  0            
  0            
  0            
45 0 0         $weights = $data->{weights} if exists $data->{weights};
46 0 0         $status = $data->{status} if exists $data->{status};
47 0 0         $coverage = $data->{coverage} if exists $data->{coverage};
48 0 0         $url = $data->{url} if exists $data->{url};
49 0 0         $groups = $data->{groups} if exists $data->{groups};
50 0 0         $force = $data->{force} if exists $data->{force};
51             }
52              
53             method to_hash {
54             my %obj = (
55             key => $key,
56             variations => $variations,
57             weights => $weights,
58             active => $active,
59             coverage => $coverage // 1,
60             condition => $condition,
61             namespace => $namespace,
62             force => $force,
63             hash_attribute => $hash_attribute,
64             hash_version => $hash_version,
65             ranges => $ranges,
66             meta => $meta,
67             filters => $filters,
68             seed => $seed,
69             name => $name,
70             phase => $phase,
71             );
72              
73             $obj{fallback_attribute} = $fallback_attribute if defined $fallback_attribute;
74             $obj{disable_sticky_bucketing} = 1 if $disable_sticky_bucketing;
75             $obj{bucket_version} = bucket_version if $bucket_version;
76             $obj{min_bucket_version} = min_bucket_version if $min_bucket_version;
77             $obj{parent_conditions} = parent_conditions if $parent_conditions;
78              
79             return \%obj;
80             }
81             }
82              
83             1;