Module: LaunchDarkly::Impl::EvaluatorHelpers
- Defined in:
- lib/ldclient-rb/impl/evaluator_helpers.rb
Overview
Class Method Summary collapse
- .context_key_in_target_list(context, kind, keys) ⇒ Boolean
- .evaluation_detail_for_off_variation(flag, reason) ⇒ Object
- .evaluation_detail_for_variation(flag, index, reason) ⇒ Object
Class Method Details
.context_key_in_target_list(context, kind, keys) ⇒ Boolean
39 40 41 42 43 44 45 46 47 |
# File 'lib/ldclient-rb/impl/evaluator_helpers.rb', line 39 def self.context_key_in_target_list(context, kind, keys) return false unless keys.is_a? Enumerable return false if keys.empty? matched_context = context.individual_context(kind || LaunchDarkly::LDContext::KIND_DEFAULT) return false if matched_context.nil? keys.include? matched_context.key end |
.evaluation_detail_for_off_variation(flag, reason) ⇒ Object
13 14 15 16 |
# File 'lib/ldclient-rb/impl/evaluator_helpers.rb', line 13 def self.evaluation_detail_for_off_variation(flag, reason) index = flag.off_variation index.nil? ? EvaluationDetail.new(nil, nil, reason) : evaluation_detail_for_variation(flag, index, reason) end |
.evaluation_detail_for_variation(flag, index, reason) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/ldclient-rb/impl/evaluator_helpers.rb', line 23 def self.evaluation_detail_for_variation(flag, index, reason) vars = flag.variations if index < 0 || index >= vars.length EvaluationDetail.new(nil, nil, EvaluationReason::error(EvaluationReason::ERROR_MALFORMED_FLAG)) # This error condition has already been logged at the time we received the flag data - see model/feature_flag.rb else EvaluationDetail.new(vars[index], index, reason) end end |