File Coverage

blib/lib/WebService/GrowthBook/FeatureResult.pm
Criterion Covered Total %
statement 20 24 83.3
branch n/a
condition n/a
subroutine 7 9 77.7
pod 0 3 0.0
total 27 36 75.0


line stmt bran cond sub pod time code
1             package WebService::GrowthBook::FeatureResult;
2 5     5   370863 use strict;
  5         14  
  5         258  
3 5     5   31 use warnings;
  5         24  
  5         339  
4 5     5   1056 no indirect;
  5         3323  
  5         31  
5 5     5   1700 use Object::Pad;
  5         25604  
  5         40  
6 5     5   1345 use Log::Any qw($log);
  5         12590  
  5         46  
7 5     5   4815 use JSON::MaybeXS;
  5         16293  
  5         1527  
8              
9             our $VERSION = '0.003'; ## VERSION
10              
11             class WebService::GrowthBook::FeatureResult{
12 0     0 0 0 field $feature_id :param :reader;
  0         0  
13 26     26 0 92 field $value :param :reader;
  26         171  
14 0     0 0   field $source :param :reader //= '';
15 0           field $experiment :param //= undef;
16             field $experiment_result :param //= undef;
17             field $rule_id :param //= undef;
18              
19             method on{
20             return $value ? 1 : 0;
21             }
22             method off{
23             my $result = $self->on;
24             return $result ? 0 : 1;
25             }
26              
27             method to_hash {
28             my %data = (
29             value => $value,
30             source => $source,
31             on => $self->on,
32             off => $self->off,
33             );
34              
35             $data{ruleId} = $rule_id if defined $rule_id;
36             $data{experiment} = $experiment->to_hash() if defined $experiment;
37             $data{experimentResult} = $experiment_result->to_hash() if defined $experiment_result;
38             return \%data;
39             }
40             }