Class: Chronicle::ETL::SortTransformer
- Inherits:
-
Transformer
- Object
- Transformer
- Chronicle::ETL::SortTransformer
- Defined in:
- lib/chronicle/etl/transformers/sort_transformer.rb
Instance Attribute Summary
Attributes inherited from Transformer
Attributes included from Registry::SelfRegistering
Instance Method Summary collapse
Methods inherited from Transformer
#call, #call_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
#finish ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/chronicle/etl/transformers/sort_transformer.rb', line 18 def finish return unless @stashed_records&.any? sorted = @stashed_records.sort_by do |record| value = record.data[@config.key] value.nil? ? [1] : [0, value] end sorted.reverse! if @config.direction == 'desc' sorted end |
#transform(record) ⇒ Object
14 15 16 |
# File 'lib/chronicle/etl/transformers/sort_transformer.rb', line 14 def transform(record) stash_record(record) end |