Class: LaunchDarkly::EvaluationDetail
- Inherits:
-
Object
- Object
- LaunchDarkly::EvaluationDetail
- Defined in:
- lib/ldclient-rb/evaluation_detail.rb
Overview
an explanation of how it was calculated.
Instance Attribute Summary collapse
-
#reason ⇒ EvaluationReason
readonly
An object describing the main factor that influenced the flag evaluation value.
-
#value ⇒ Object
readonly
The result of the flag evaluation.
-
#variation_index ⇒ int|nil
readonly
The index of the returned value within the flag's list of variations.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#default_value? ⇒ Boolean
Tests whether the flag evaluation returned a default value.
-
#initialize(value, variation_index, reason) ⇒ EvaluationDetail
constructor
Creates a new instance.
Constructor Details
#initialize(value, variation_index, reason) ⇒ EvaluationDetail
Creates a new instance.
12 13 14 15 16 17 18 19 |
# File 'lib/ldclient-rb/evaluation_detail.rb', line 12 def initialize(value, variation_index, reason) raise ArgumentError.new("variation_index must be a number") if !variation_index.nil? && !(variation_index.is_a? Numeric) raise ArgumentError.new("reason must be an EvaluationReason") unless reason.is_a? EvaluationReason @value = value @variation_index = variation_index @reason = reason end |
Instance Attribute Details
#reason ⇒ EvaluationReason (readonly)
An object describing the main factor that influenced the flag evaluation value.
43 44 45 |
# File 'lib/ldclient-rb/evaluation_detail.rb', line 43 def reason @reason end |
#value ⇒ Object (readonly)
The result of the flag evaluation. This will be either one of the flag's variations, or the default value that was passed to LDClient#variation_detail. It is the same as the return value of LDClient#variation.
28 29 30 |
# File 'lib/ldclient-rb/evaluation_detail.rb', line 28 def value @value end |
#variation_index ⇒ int|nil (readonly)
The index of the returned value within the flag's list of variations. The first variation is
0, the second is 1, etc. This is nil
if the default value was returned.
36 37 38 |
# File 'lib/ldclient-rb/evaluation_detail.rb', line 36 def variation_index @variation_index end |
Instance Method Details
#==(other) ⇒ Object
55 56 57 |
# File 'lib/ldclient-rb/evaluation_detail.rb', line 55 def ==(other) @value == other.value && @variation_index == other.variation_index && @reason == other.reason end |
#default_value? ⇒ Boolean
Tests whether the flag evaluation returned a default value. This is the same as checking whether #variation_index is nil.
51 52 53 |
# File 'lib/ldclient-rb/evaluation_detail.rb', line 51 def default_value? variation_index.nil? end |