Class: LaunchDarkly::Impl::Model::EvalResultFactoryMultiVariations

Inherits:
Object
  • Object
show all
Defined in:
lib/ldclient-rb/impl/model/preprocessed_data.rb

Overview

Container for a set of precomputed results, one for each possible flag variation.

Since:

  • 5.5.0

Instance Method Summary collapse

Constructor Details

#initialize(variation_factories) ⇒ EvalResultFactoryMultiVariations

Returns a new instance of EvalResultFactoryMultiVariations.

Since:

  • 5.5.0



31
32
33
# File 'lib/ldclient-rb/impl/model/preprocessed_data.rb', line 31

def initialize(variation_factories)
  @factories = variation_factories
end

Instance Method Details

#for_variation(index, in_experiment) ⇒ LaunchDarkly::EvaluationDetail

Parameters:

  • index (Integer)

    the variation index

  • in_experiment (Boolean)

    indicates whether we want the result to include “inExperiment: true” in the reason or not

Returns:

Since:

  • 5.5.0



39
40
41
42
43
44
45
# File 'lib/ldclient-rb/impl/model/preprocessed_data.rb', line 39

def for_variation(index, in_experiment)
  if index < 0 || index >= @factories.length
    EvaluationDetail.new(nil, nil, EvaluationReason.error(EvaluationReason::ERROR_MALFORMED_FLAG))
  else
    @factories[index].get_result(in_experiment)
  end
end