Class: Ruby::Rego::Policy
- Inherits:
-
Object
- Object
- Ruby::Rego::Policy
- Defined in:
- lib/ruby/rego/policy.rb
Overview
Compiled policy for reuse across evaluations.
Instance Method Summary collapse
-
#evaluate(input: {}, data: {}, query: nil) ⇒ Result?
Evaluate the policy with the provided input and query.
-
#initialize(source, environment_pool: EnvironmentPool.new) ⇒ Policy
constructor
Create a compiled policy from source.
Constructor Details
#initialize(source, environment_pool: EnvironmentPool.new) ⇒ Policy
Create a compiled policy from source.
16 17 18 19 20 |
# File 'lib/ruby/rego/policy.rb', line 16 def initialize(source, environment_pool: EnvironmentPool.new) @source = source.to_s @compiled_module = Ruby::Rego.compile(@source) @environment_pool = environment_pool end |
Instance Method Details
#evaluate(input: {}, data: {}, query: nil) ⇒ Result?
Evaluate the policy with the provided input and query.
28 29 30 |
# File 'lib/ruby/rego/policy.rb', line 28 def evaluate(input: {}, data: {}, query: nil) ErrorHandling.wrap("evaluation") { evaluate_with_pool(input: input, data: data, query: query) } end |