Sha256: b87bf8beb7859a8acecc31402d0c95ea89aa9eeb07ca5aaf3b841143fe24acad
Contents?: true
Size: 666 Bytes
Versions: 1
Compression:
Stored size: 666 Bytes
Contents
# frozen_string_literal: true require 'chronicle/utils/hash_utils' module Chronicle module ETL # A transformer that filters the fields of a record and returns a new hash with only the specified fields. class FieldsLimitTransformer < Chronicle::ETL::Transformer register_connector do |r| r.identifier = :fields_limit r.description = 'by taking first N fields' end setting :limit, type: :numeric, default: 10 def transform(record) # flattern hash and then take the first limit fields Chronicle::Utils::HashUtils.flatten_hash(record.data.to_h).first(@config.limit).to_h 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/fields_limit_transformer.rb |