Module: Liteguard::Evaluation

Defined in:
lib/liteguard/evaluation.rb

Overview

Local rule evaluation engine — all evaluation is done without network calls.

Class Method Summary collapse

Class Method Details

.evaluate_guard(guard, properties) ⇒ Boolean

Evaluate a guard against a property hash.

Rules are processed in order and the first matching rule determines the result. If no enabled rule matches, the guard’s configured default value is returned.

Parameters:

  • guard (Guard)

    guard definition to evaluate

  • properties (Hash{String => Object})

    normalized evaluation properties

Returns:

  • (Boolean)

    the resolved open/closed result



13
14
15
16
17
18
19
# File 'lib/liteguard/evaluation.rb', line 13

def self.evaluate_guard(guard, properties)
  guard.rules.each do |rule|
    next unless rule.enabled
    return rule.result if matches_rule?(rule, properties)
  end
  guard.default_value
end