Sha256: f33a24ffdef68fdb3698d7eb79a078d3f4afeb473d09a708607d2877ad4b466f
Contents?: true
Size: 732 Bytes
Versions: 1
Compression:
Stored size: 732 Bytes
Contents
# frozen_string_literal: true module Chronicle module ETL # Return only records that match all the conditions of the filters # setting. class FilterTransformer < Chronicle::ETL::Transformer register_connector do |r| r.identifier = :filter r.description = 'by only accepting records that match conditions' end setting :filters, type: :hash def transform(record) record_hash = record.data.to_h @config.filters.each do |key, value| path = key.split('.').map do |k| k.match?(/^\d+$/) ? k.to_i : k.to_sym end return nil unless record_hash.dig(*path) == value end record.data end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chronicle-etl-0.6.1 | lib/chronicle/etl/transformers/filter_transformer.rb |