Class: Chronicle::ETL::FieldsLimitTransformer

Inherits:
Transformer
  • Object
show all
Defined in:
lib/chronicle/etl/transformers/fields_limit_transformer.rb

Overview

A transformer that filters the fields of a record and returns a new hash with only the specified fields.

Instance Attribute Summary

Attributes inherited from Transformer

#stashed_records

Attributes included from Registry::SelfRegistering

#connector_registration

Instance Method Summary collapse

Methods inherited from Transformer

#call, #call_finish, #finish, #initialize

Methods included from Registry::SelfRegistering

#register_connector

Methods included from Configurable

included

Constructor Details

This class inherits a constructor from Chronicle::ETL::Transformer

Instance Method Details

#transform(record) ⇒ Object



16
17
18
19
20
# File 'lib/chronicle/etl/transformers/fields_limit_transformer.rb', line 16

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