Module: CSVDecision::Input
- Defined in:
- lib/csv_decision/input.rb
Overview
Parse the input hash.
Class Method Summary collapse
-
.parse(table:, input:, symbolize_keys:) ⇒ 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.
Class Method Details
.parse(table:, input:, symbolize_keys:) ⇒ 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.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/csv_decision/input.rb', line 15 def self.parse(table:, input:, symbolize_keys:) validate(input) # For safety the default is to symbolize keys and make a copy of the hash. # However, if this is turned off then the keys must already symbolized. input = symbolize_keys ? input.symbolize_keys : input parsed_input = parse_input(table: table, input: input) # Freeze the copy of the input hash we just created. parsed_input[:hash].freeze if symbolize_keys parsed_input end |