Class: Ruby::Rego::Evaluator::VariableCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/rego/evaluator/variable_collector.rb

Overview

Collects variable names referenced in expressions and query literals. The node-class dispatch tables, some-pattern name extraction, and bound-variable collection live in variable_collector/bound_variable_collector.rb, required at the bottom. :reek:TooManyMethods

Instance Method Summary collapse

Constructor Details

#initializeVariableCollector

Returns a new instance of VariableCollector.



12
13
14
15
# File 'lib/ruby/rego/evaluator/variable_collector.rb', line 12

def initialize
  @names = [] # @type var @names: Array[String]
  @local_scopes = [] # @type var @local_scopes: Array[Array[String]]
end

Instance Method Details

#collect(node) ⇒ Array<String>

Parameters:

  • node (Object)

Returns:

  • (Array<String>)


19
20
21
22
# File 'lib/ruby/rego/evaluator/variable_collector.rb', line 19

def collect(node)
  collect_node(node)
  names
end

#collect_literals(literals) ⇒ Array<String>

Parameters:

  • literals (Array<Object>)

Returns:

  • (Array<String>)


26
27
28
29
# File 'lib/ruby/rego/evaluator/variable_collector.rb', line 26

def collect_literals(literals)
  Array(literals).each { |literal| collect_node(literal) }
  names
end