Class: Representable::Collect

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

Overview

Collect applies a pipeline to each element of input.

Defined Under Namespace

Classes: Hash

Constant Summary

Constants inherited from Pipeline

Pipeline::Insert, Pipeline::Stop

Instance Method Summary collapse

Methods included from Pipeline::Macros

#insert

Instance Method Details

#call(input, options) ⇒ Object

when stop, the element is skipped. (should that be Skip then?)



36
37
38
39
40
41
42
43
# File 'lib/representable/pipeline.rb', line 36

def call(input, options)
  arr = []
  input.each_with_index do |item_fragment, i|
    result = super(item_fragment, options.merge(index: i)) # DISCUSS: NO :fragment set.
    Pipeline::Stop == result ? next : arr << result
  end
  arr
end