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.
-
#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) ⇒ FeatureResult
constructor
A new instance of FeatureResult.
- #to_json(*_args) ⇒ Object
Constructor Details
#initialize(value, source, experiment, experiment_result) ⇒ FeatureResult
Returns a new instance of FeatureResult.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/growthbook/feature_result.rb', line 30 def initialize( value, source, experiment, experiment_result ) on = !value.nil? && value != 0 && value != '' && value != false @value = value @on = on @off = !on @source = source @experiment = experiment @experiment_result = experiment_result 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 |
#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
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/growthbook/feature_result.rb', line 47 def to_json(*_args) json = {} json['on'] = @on json['off'] = @off json['value'] = @value json['source'] = @source if @experiment json['experiment'] = @experiment.to_json json['experimentResult'] = @experiment_result.to_json end json end |