Class: Chronicle::ETL::FilterTransformer
- Inherits:
-
Transformer
- Object
- Transformer
- Chronicle::ETL::FilterTransformer
- Defined in:
- lib/chronicle/etl/transformers/filter_transformer.rb
Overview
Return only records that match all the conditions of the filters setting.
Instance Attribute Summary
Attributes inherited from Transformer
Attributes included from Registry::SelfRegistering
Instance Method Summary collapse
Methods inherited from Transformer
#call, #call_finish, #finish, #initialize
Methods included from Registry::SelfRegistering
Methods included from Configurable
Constructor Details
This class inherits a constructor from Chronicle::ETL::Transformer
Instance Method Details
#transform(record) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/chronicle/etl/transformers/filter_transformer.rb', line 15 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 |