class LaunchDarkly::EvaluationDetail

An object returned by {LDClient#variation_detail}, combining the result of a flag evaluation with an explanation of how it was calculated.

Attributes

reason[R]

An object describing the main factor that influenced the flag evaluation value.

@return [EvaluationReason]

value[R]

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}.

@return [Object]

variation_index[R]

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.

@return [int|nil]

Public Class Methods

new(value, variation_index, reason) click to toggle source

Creates a new instance.

@param value the result value of the flag evaluation; may be of any type @param variation_index [int|nil] the index of the value within the flag's list of variations, or

`nil` if the application default value was returned

@param reason [EvaluationReason] an object describing the main factor that influenced the result @raise [ArgumentError] if `variation_index` or `reason` is not of the correct type

# File lib/ldclient-rb/evaluation_detail.rb, line 13
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") if !(reason.is_a? EvaluationReason)
  @value = value
  @variation_index = variation_index
  @reason = reason
end

Public Instance Methods

==(other) click to toggle source
# 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?() click to toggle source

Tests whether the flag evaluation returned a default value. This is the same as checking whether {#variation_index} is nil.

@return [Boolean]

# File lib/ldclient-rb/evaluation_detail.rb, line 51
def default_value?
  variation_index.nil?
end