Class: Representable::Collect
- 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
-
#call(input, options) ⇒ Object
when stop, the element is skipped.
Methods included from Pipeline::Macros
Instance Method Details
#call(input, options) ⇒ Object
when stop, the element is skipped. (should that be Skip then?)
37 38 39 40 41 42 43 44 |
# File 'lib/representable/pipeline.rb', line 37 def call(input, ) arr = [] input.each_with_index do |item_fragment, i| result = super(item_fragment, .merge(index: i)) # DISCUSS: NO :fragment set. Pipeline::Stop == result ? next : arr << result end arr end |