Class: JobIteration::EnumeratorBuilder::Wrapper
- Inherits:
-
Enumerator
- Object
- Enumerator
- JobIteration::EnumeratorBuilder::Wrapper
- Defined in:
- lib/job-iteration/enumerator_builder.rb
Overview
These wrappers ensure we have a custom type that we can assert on in
Iteration. It's useful that the wrapper
passed to EnumeratorBuilder in
enumerator_builder
is always the type that is returned from
build_enumerator
. This prevents people from implementing custom
Enumerators without wrapping them in
enumerator_builder.wrap(custom_enum)
. Think of these wrappers
the way you should a middleware.
Class Method Summary collapse
Class Method Details
.wrap(_builder, enum) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/job-iteration/enumerator_builder.rb', line 23 def wrap(_builder, enum) new(-> { enum.size }) do |yielder| enum.each do |*val| yielder.yield(*val) end end end |