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
# File 'lib/quonfig/evaluation.rb', line 18

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

#report_and_return(evaluation_summary_aggregator) ⇒ Object



36
37
38
39
40
# File 'lib/quonfig/evaluation.rb', line 36

def report_and_return(evaluation_summary_aggregator)
  report(evaluation_summary_aggregator)

  unwrapped_value
end

#reportable_valueObject



32
33
34
# File 'lib/quonfig/evaluation.rb', line 32

def reportable_value
  deepest_value.reportable_value
end

#unwrapped_valueObject



28
29
30
# File 'lib/quonfig/evaluation.rb', line 28

def unwrapped_value
  deepest_value.unwrap
end