Sha256: c3cf0f3f2312d496435d81dac812f44f75be3971cd9ac5ab5d9f77185a446cd6
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true class Lenjador module Preprocessors module Strategies class Mask MASK_SYMBOL = '*' MASKED_VALUE = MASK_SYMBOL * 5 def initialize(trie) @trie = trie end def process(data, pointer = '') return MASKED_VALUE unless @trie.include?(pointer) case data when Hash process_hash(data, pointer) when Array process_array(data, pointer) when String, Numeric, Symbol, Date, Time, TrueClass, FalseClass, NilClass data else MASKED_VALUE end end private def process_hash(data, parent_pointer) data.each_with_object({}) do |(key, value), result| result[key] = process(value, "#{parent_pointer}/#{key}") end end def process_array(data, parent_pointer) data.each_with_index.map do |value, index| process(value, "#{parent_pointer}/#{index}") end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lenjador-2.3.1 | lib/lenjador/preprocessors/strategies/mask.rb |
lenjador-2.3.0 | lib/lenjador/preprocessors/strategies/mask.rb |
lenjador-2.2.2 | lib/lenjador/preprocessors/strategies/mask.rb |