Class: Realize::Pipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/realize/pipeline.rb

Overview

Main runner that encapsulates a collection of transformers and knows how to kick off the transformation process.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transformers = [], resolver: Objectable.resolver) ⇒ Pipeline

Returns a new instance of Pipeline.

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
# File 'lib/realize/pipeline.rb', line 16

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

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

  freeze
end

Instance Attribute Details

#resolverObject (readonly)

Returns the value of attribute resolver.



14
15
16
# File 'lib/realize/pipeline.rb', line 14

def resolver
  @resolver
end

#transformersObject (readonly)

Returns the value of attribute transformers.



14
15
16
# File 'lib/realize/pipeline.rb', line 14

def transformers
  @transformers
end

Instance Method Details

#transform(record, time = Time.now.utc) ⇒ Object



25
26
27
28
29
# File 'lib/realize/pipeline.rb', line 25

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