Class: LaunchDarkly::EvaluationDetail

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#reasonHash (readonly)

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

Returns:

  • (Hash)

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



23
24
25
# File 'lib/ldclient-rb/evaluation.rb', line 23

def reason
  @reason
end

#valueObject (readonly)

Returns The result of the flag evaluation. This will be either one of the flag’s variations or the default value that was passed to the ‘variation` method.

Returns:

  • (Object)

    The result of the flag evaluation. This will be either one of the flag’s variations or the default value that was passed to the ‘variation` method.



16
17
18
# File 'lib/ldclient-rb/evaluation.rb', line 16

def value
  @value
end

#variation_indexint|nil (readonly)

Returns The index of the returned value within the flag’s list of variations, e.g. 0 for the first variation - or ‘nil` if the default value was returned.

Returns:

  • (int|nil)

    The index of the returned value within the flag’s list of variations, e.g. 0 for the first variation - or ‘nil` if the default value was returned.



20
21
22
# File 'lib/ldclient-rb/evaluation.rb', line 20

def variation_index
  @variation_index
end

Instance Method Details

#==(other) ⇒ Object



31
32
33
# File 'lib/ldclient-rb/evaluation.rb', line 31

def ==(other)
  @value == other.value && @variation_index == other.variation_index && @reason == other.reason
end

#default_value?boolean

Returns True if the flag evaluated to the default value rather than to one of its variations.

Returns:

  • (boolean)

    True if the flag evaluated to the default value rather than to one of its variations.



27
28
29
# File 'lib/ldclient-rb/evaluation.rb', line 27

def default_value?
  variation_index.nil?
end