Class: LaunchDarkly::EvaluationDetail

Inherits:
Object
  • Object
show all
Defined in:
lib/ldclient-rb/evaluation_detail.rb

Overview

an explanation of how it was calculated.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, variation_index, reason) ⇒ EvaluationDetail

Creates a new instance.

Parameters:

  • value

    the result value of the flag evaluation; may be of any type

  • 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

  • reason (EvaluationReason)

    an object describing the main factor that influenced the result

Raises:

  • (ArgumentError)

    if variation_index or reason is not of the correct type



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

#reasonEvaluationReason (readonly)

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

Returns:



43
44
45
# File 'lib/ldclient-rb/evaluation_detail.rb', line 43

def reason
  @reason
end

#valueObject (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.

Returns:

  • (Object)


28
29
30
# File 'lib/ldclient-rb/evaluation_detail.rb', line 28

def value
  @value
end

#variation_indexint|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.

Returns:

  • (int|nil)


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.

Returns:

  • (Boolean)


51
52
53
# File 'lib/ldclient-rb/evaluation_detail.rb', line 51

def default_value?
  variation_index.nil?
end