Class: LaunchDarkly::EvaluationDetail
- Inherits:
-
Object
- Object
- LaunchDarkly::EvaluationDetail
- Defined in:
- lib/ldclient-rb/evaluation.rb
Overview
An object returned by LDClient#variation_detail, combining the result of a flag evaluation with an explanation of how it was calculated.
Instance Attribute Summary collapse
-
#reason ⇒ Hash
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
A new instance of EvaluationDetail.
Constructor Details
#initialize(value, variation_index, reason) ⇒ EvaluationDetail
Returns a new instance of EvaluationDetail.
8 9 10 11 12 |
# File 'lib/ldclient-rb/evaluation.rb', line 8 def initialize(value, variation_index, reason) @value = value @variation_index = variation_index @reason = reason end |
Instance Attribute Details
#reason ⇒ Hash (readonly)
An object describing the main factor that influenced the flag evaluation value.
This object is currently represented as a Hash, which may have the following keys:
:kind
: The general category of reason. Possible values:
'OFF'
: the flag was off and therefore returned its configured off value'FALLTHROUGH'
: the flag was on but the user did not match any targets or rules'TARGET_MATCH'
: the user key was specifically targeted for this flag'RULE_MATCH'
: the user matched one of the flag's rules'PREREQUISITE_FAILED
': the flag was considered off because it had at least one prerequisite flag that either was off or did not return the desired variation'ERROR'
: the flag could not be evaluated, so the default value was returned
:ruleIndex
: If the kind was RULE_MATCH
, this is the positional index of the
matched rule (0 for the first rule).
:ruleId
: If the kind was RULE_MATCH
, this is the rule's unique identifier.
:prerequisiteKey
: If the kind was PREREQUISITE_FAILED
, this is the flag key of
the prerequisite flag that failed.
:errorKind
: If the kind was ERROR
, this indicates the type of error:
'CLIENT_NOT_READY'
: the caller tried to evaluate a flag before the client had successfully initialized'FLAG_NOT_FOUND'
: the caller provided a flag key that did not match any known flag'MALFORMED_FLAG'
: there was an internal inconsistency in the flag data, e.g. a rule specified a nonexistent variation'USER_NOT_SPECIFIED'
: the user object or user key was not provied'EXCEPTION'
: an unexpected exception stopped flag evaluation
66 67 68 |
# File 'lib/ldclient-rb/evaluation.rb', line 66 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.
21 22 23 |
# File 'lib/ldclient-rb/evaluation.rb', line 21 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.
29 30 31 |
# File 'lib/ldclient-rb/evaluation.rb', line 29 def variation_index @variation_index end |
Instance Method Details
#==(other) ⇒ Object
78 79 80 |
# File 'lib/ldclient-rb/evaluation.rb', line 78 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.
74 75 76 |
# File 'lib/ldclient-rb/evaluation.rb', line 74 def default_value? variation_index.nil? end |