Module: CSVDecision::Input Private

Defined in:
lib/csv_decision/input.rb

Overview

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

Parse the input hash.

Class Method Summary collapse

Class Method Details

.parse(table:, input:, symbolize_keys:) ⇒ Hash{Symbol => Hash{Symbol=>Object}, Hash{Integer=>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.

Returns a hash of two hashes:

  • hash: either a copy with keys symbolized or the original input object

  • scan_cols: Picks out the value in the input hash for each table input column. Defaults to nil if the key is missing in the input hash.

Parameters:

  • table (CSVDecision::Table)

    Decision table.

  • input (Hash)

    Input hash (keys may or may not be symbolized)

  • symbolize_keys (true, false)

    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 => Hash{Symbol=>Object}, Hash{Integer=>Object}})

    Returns a hash of two hashes:

    • hash: either a copy with keys symbolized or the original input object

    • scan_cols: Picks out the value in the input hash for each table input column. Defaults to nil if the key is missing in the input hash.



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

def self.parse(table:, input:, symbolize_keys:)
  validate(input)

  parsed_input =
    parse_input(table: table, input: input(table, input, symbolize_keys))

  # We can freeze it as we made our own copy
  parsed_input[:hash].freeze if symbolize_keys

  parsed_input.freeze
end