Class: Pipe::Reducer
- Inherits:
-
Object
- Object
- Pipe::Reducer
- Defined in:
- lib/pipe/reducer.rb
Instance Method Summary collapse
-
#initialize(config:, context:, subject:, through:) ⇒ Reducer
constructor
A new instance of Reducer.
- #reduce ⇒ Object
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
#reduce ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/pipe/reducer.rb', line 10 def reduce through.reduce(subject) { |subj, method| begin break subj if config.break?(subj, method, through) process(subj, method) rescue => e payload = {:error => e, :method => method, :subject => subj} handle_error(payload) break error_response(payload) end } end |