Sha256: b395d0a4bda7a99a1fb1e4a5d77dd7d04ea97e86036824546a303ea6a7ba1aad

Contents?: true

Size: 849 Bytes

Versions: 3

Compression:

Stored size: 849 Bytes

Contents

# frozen_string_literal: true

#
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#

module Realize
  # Main runner that encapsulates a collection of transformers and knows how to kick off the
  # transformation process.
  class Pipeline
    attr_reader :resolver, :transformers

    def initialize(transformers = [], resolver: Objectable.resolver)
      raise ArgumentError, 'resolver is required' unless resolver

      @resolver     = resolver
      @transformers = Transformers.array(transformers)

      freeze
    end

    def transform(record, time = Time.now.utc)
      transformers.inject(record) do |memo, transformer|
        transformer.transform(resolver, memo, time, record)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
realize-1.6.0 lib/realize/pipeline.rb
realize-1.5.0 lib/realize/pipeline.rb
realize-1.4.0 lib/realize/pipeline.rb