Class: CSVDecision::Scan Private

Inherits:
Object
  • Object
show all
Defined in:
lib/csv_decision/scan.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Scan the input hash for all the paths specified in the decision table

Defined Under Namespace

Classes: InputHashes

Class Method Summary collapse

Class Method Details

.table(table:, input:, symbolize_keys:) ⇒ Hash{Symbol=>Object}

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Main method for making decisions with a table that has paths.

Parameters:

  • table (CSVDecision::Table)

    Decision table.

  • input (Hash)

    Input hash (keys may or may not be symbolized)

  • symbolize_keys (Boolean)

    Set to false if keys are symbolized and it’s OK to mutate the input hash. Otherwise a copy of the input hash is symbolized.

Returns:

  • (Hash{Symbol=>Object})

    Decision result.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/csv_decision/scan.rb', line 18

def self.table(table:, input:, symbolize_keys:)
  input = symbolize_keys ? input.deep_symbolize_keys : input
  decision = Decision.new(table: table)
  input_hashes = InputHashes.new

  if table.options[:first_match]
    scan_first_match(input: input, decision: decision, input_hashes: input_hashes)
  else
    scan_accumulate(input: input, decision: decision, input_hashes: input_hashes)
  end
end