Class: Pipe::Reducer

Inherits:
Object
  • Object
show all
Defined in:
lib/pipe/reducer.rb

Instance Method Summary collapse

Constructor Details

#initialize(config:, context:, subject:, through:) ⇒ Reducer

Returns a new instance of Reducer.



3
4
5
6
7
8
# File 'lib/pipe/reducer.rb', line 3

def initialize(config:, context:, subject:, through:)
  self.config = config
  self.context = context
  self.subject = subject
  self.through = through
end

Instance Method Details

#reduceObject



10
11
12
13
14
15
# File 'lib/pipe/reducer.rb', line 10

def reduce
  through.reduce(subject) { |subj, method|
    break subj if config.break?(subj, method, through)
    process(subj, method)
  }
end