Class: Growthbook::FeatureResult
- Inherits:
-
Object
- Object
- Growthbook::FeatureResult
- Defined in:
- lib/growthbook/feature_result.rb
Overview
Result of a feature evaluation
Instance Attribute Summary collapse
-
#experiment ⇒ Growthbook::InlineExperiment?
readonly
The experiment used to decide the feature value.
-
#experiment_result ⇒ Growthbook::InlineExperimentResult?
readonly
The result of the experiment.
-
#off ⇒ Bool
readonly
Whether or not the feature is OFF.
-
#on ⇒ Bool
readonly
Whether or not the feature is ON.
-
#rule_id ⇒ String
readonly
The id of the rule (if any) that was used to assign the value.
-
#source ⇒ String
readonly
The reason the feature was assigned this value.
-
#value ⇒ Any?
readonly
The assigned value of the feature.
Instance Method Summary collapse
-
#initialize(value, source, experiment, experiment_result, rule_id = '') ⇒ FeatureResult
constructor
A new instance of FeatureResult.
- #to_json(*_args) ⇒ Object
Constructor Details
#initialize(value, source, experiment, experiment_result, rule_id = '') ⇒ FeatureResult
Returns a new instance of FeatureResult.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/growthbook/feature_result.rb', line 34 def initialize( value, source, experiment, experiment_result, rule_id = '' ) on = !value.nil? && value != 0 && value != '' && value != false @value = value @on = on @off = !on @source = source @experiment = experiment @experiment_result = experiment_result @rule_id = rule_id || '' end |
Instance Attribute Details
#experiment ⇒ Growthbook::InlineExperiment? (readonly)
The experiment used to decide the feature value
24 25 26 |
# File 'lib/growthbook/feature_result.rb', line 24 def experiment @experiment end |
#experiment_result ⇒ Growthbook::InlineExperimentResult? (readonly)
The result of the experiment
28 29 30 |
# File 'lib/growthbook/feature_result.rb', line 28 def experiment_result @experiment_result end |
#off ⇒ Bool (readonly)
Whether or not the feature is OFF
16 17 18 |
# File 'lib/growthbook/feature_result.rb', line 16 def off @off end |
#on ⇒ Bool (readonly)
Whether or not the feature is ON
12 13 14 |
# File 'lib/growthbook/feature_result.rb', line 12 def on @on end |
#rule_id ⇒ String (readonly)
The id of the rule (if any) that was used to assign the value
32 33 34 |
# File 'lib/growthbook/feature_result.rb', line 32 def rule_id @rule_id end |
#source ⇒ String (readonly)
The reason the feature was assigned this value
20 21 22 |
# File 'lib/growthbook/feature_result.rb', line 20 def source @source end |
#value ⇒ Any? (readonly)
The assigned value of the feature
8 9 10 |
# File 'lib/growthbook/feature_result.rb', line 8 def value @value end |
Instance Method Details
#to_json(*_args) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/growthbook/feature_result.rb', line 53 def to_json(*_args) json = {} json['on'] = @on json['off'] = @off json['value'] = @value json['source'] = @source json['ruleId'] = @rule_id if @experiment json['experiment'] = @experiment.to_json json['experimentResult'] = @experiment_result.to_json end json end |