Class: Ruby::Rego::Evaluator::BoundVariableCollector
- Inherits:
-
Object
- Object
- Ruby::Rego::Evaluator::BoundVariableCollector
- Defined in:
- lib/ruby/rego/evaluator/variable_collector.rb
Overview
Collects variable names that become bound inside query bodies.
Instance Method Summary collapse
-
#collect(literals) ⇒ Array<String>
-
#collect_details(literals) ⇒ Hash<Symbol, Array<String>>
:reek:TooManyStatements.
-
#initialize ⇒ BoundVariableCollector
constructor
A new instance of BoundVariableCollector.
Constructor Details
#initialize ⇒ BoundVariableCollector
Returns a new instance of BoundVariableCollector.
61 62 63 64 |
# File 'lib/ruby/rego/evaluator/variable_collector.rb', line 61 def initialize @explicit_names = [] # @type var @explicit_names: Array[String] @unify_names = [] # @type var @unify_names: Array[String] end |
Instance Method Details
#collect(literals) ⇒ Array<String>
68 69 70 |
# File 'lib/ruby/rego/evaluator/variable_collector.rb', line 68 def collect(literals) collect_details(literals)[:all] end |
#collect_details(literals) ⇒ Hash<Symbol, Array<String>>
:reek:TooManyStatements
75 76 77 78 79 80 81 |
# File 'lib/ruby/rego/evaluator/variable_collector.rb', line 75 def collect_details(literals) reset Array(literals).each { |literal| collect_from_literal(literal) } explicit = explicit_names.uniq unification = unify_names.uniq { explicit: explicit, unification: unification, all: (explicit + unification).uniq } end |