Class: Fall::RecordOperationPipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/fall/record_operation_pipeline.rb

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ RecordOperationPipeline

Returns a new instance of RecordOperationPipeline.



3
4
5
6
# File 'lib/fall/record_operation_pipeline.rb', line 3

def initialize(source)
  @source = source
  @operation = RecordOperation.new(->(args) { args })
end

Instance Method Details

#add_operation(operation) ⇒ Object Also known as: add_record_operation



8
9
10
# File 'lib/fall/record_operation_pipeline.rb', line 8

def add_operation(operation)
  @operation = @operation.chain(operation)
end

#to_enumObject



14
15
16
17
18
19
20
21
22
# File 'lib/fall/record_operation_pipeline.rb', line 14

def to_enum(...)
  @source
    .lazy
    .map { |value| Record.wrap(value) }
    .map { |record| @operation.call(record) }
    .reject(&:discard?)
    .map(&:value)
    .to_enum(...)
end