class CSVDecision::Scan::InputHashes
Derive the parsed input hash, using a cache for speed.
Public Class Methods
new()
click to toggle source
# File lib/csv_decision/scan.rb, line 86 def initialize @input_hashes = {} end
Public Instance Methods
data(decision:, path:, input:)
click to toggle source
@param path [Array<Symbol] Path for the input hash. @param input [Hash{Symbol=>Object}] Input
hash. @return [Hash{Symbol=>Object}] Parsed input hash.
# File lib/csv_decision/scan.rb, line 93 def data(decision:, path:, input:) result = input(decision: decision, path: path, input: input) decision.input(result) unless result == {} result end
Private Instance Methods
input(decision:, path:, input:)
click to toggle source
# File lib/csv_decision/scan.rb, line 103 def input(decision:, path:, input:) return @input_hashes[path] if @input_hashes.key?(path) # Use the path - an array of symbol keys, to dig out the input sub-hash hash = path.empty? ? input : input.dig(*path) # Parse and transform the hash supplied as input data = hash.blank? ? {} : Input.parse_data(table: decision.table, input: hash) # Cache the parsed input hash data for this path @input_hashes[path] = data end