Class: Quonfig::Evaluation

Inherits:
Object
  • Object
show all
Defined in:
lib/quonfig/evaluation.rb

Overview

Records the result of evaluating a config’s criteria and forensics for reporting

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config:, value:, value_index:, config_row_index:, context:, resolver:, conditional_value: nil) ⇒ Evaluation

Returns a new instance of Evaluation.



8
9
10
11
12
13
14
15
16
# File 'lib/quonfig/evaluation.rb', line 8

def initialize(config:, value:, value_index:, config_row_index:, context:, resolver:, conditional_value: nil)
  @config = config
  @value = value
  @value_index = value_index
  @config_row_index = config_row_index
  @context = context
  @resolver = resolver
  @conditional_value = conditional_value
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



6
7
8
# File 'lib/quonfig/evaluation.rb', line 6

def context
  @context
end

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'lib/quonfig/evaluation.rb', line 6

def value
  @value
end

Instance Method Details

#reasonObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/quonfig/evaluation.rb', line 18

def reason
  @reason ||= if @conditional_value
                Quonfig::Reason.compute(
                  config: @config,
                  conditional_value: @conditional_value,
                  weighted_value_index: deepest_value.weighted_value_index
                )
              else
                Quonfig::Reason::UNKNOWN
              end
end

#report_and_return(evaluation_summary_aggregator) ⇒ Object



38
39
40
41
42
# File 'lib/quonfig/evaluation.rb', line 38

def report_and_return(evaluation_summary_aggregator)
  report(evaluation_summary_aggregator)

  unwrapped_value
end

#reportable_valueObject



34
35
36
# File 'lib/quonfig/evaluation.rb', line 34

def reportable_value
  deepest_value.reportable_value
end

#unwrapped_valueObject



30
31
32
# File 'lib/quonfig/evaluation.rb', line 30

def unwrapped_value
  deepest_value.unwrap
end