Class: RegoValidate::PolicyEvaluator
- Inherits:
-
Object
- Object
- RegoValidate::PolicyEvaluator
- Defined in:
- lib/ruby/rego/cli.rb
Overview
Compiles and evaluates policies with a resolved query.
Instance Method Summary collapse
-
#evaluate ⇒ EvaluationResult
Compile and evaluate the policy using the resolved query.
-
#initialize(policy_source, input, query, profiler: nil) ⇒ PolicyEvaluator
constructor
Create a policy evaluator.
Constructor Details
#initialize(policy_source, input, query, profiler: nil) ⇒ PolicyEvaluator
Create a policy evaluator.
742 743 744 745 746 747 |
# File 'lib/ruby/rego/cli.rb', line 742 def initialize(policy_source, input, query, profiler: nil) @policy_source = policy_source @input = input @query = query @profiler = profiler end |
Instance Method Details
#evaluate ⇒ EvaluationResult
Compile and evaluate the policy using the resolved query.
752 753 754 755 756 757 758 759 760 |
# File 'lib/ruby/rego/cli.rb', line 752 def evaluate compiled_module = measure("compile") { Ruby::Rego.compile(policy_source) } query_path = resolve_query(compiled_module) return EvaluationResult.new(error_message: "No default validation rule found. Provide --query.") unless query_path build_evaluation(compiled_module, query_path) ensure profiler&.report end |