Sha256: 2af7bcd923eb5f367afd88d7db61bc3e437eb169bac5bc0e066779c637f8b2f9
Contents?: true
Size: 1006 Bytes
Versions: 7
Compression:
Stored size: 1006 Bytes
Contents
class Logasm module Preprocessors module Strategies class Prune def initialize(trie) @trie = trie end def process(data, pointer = '') return nil unless @trie.include?(pointer) case data when Hash process_hash(data, pointer) when Array process_array(data, pointer) else data end end private def process_hash(data, parent_pointer) data.each_with_object({}) do |(key, value), result| path = "#{parent_pointer}/#{key}" result[key] = process(value, path) if @trie.include?(path) end end def process_array(data, parent_pointer) data.each_with_index.each_with_object([]) do |(value, index), result| path = "#{parent_pointer}/#{index}" result << process(value, path) if @trie.include?(path) end end end end end end
Version data entries
7 entries across 7 versions & 2 rubygems