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). We don't do this yet for backwards
compatibility with raw calls to EnumeratorBuilder. Think of these wrappers
the way you should a middleware.
Class Method Summary collapse
Class Method Details
.wrap(_builder, enum) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/job-iteration/enumerator_builder.rb', line 18 def self.wrap(_builder, enum) new(-> { enum.size }) do |yielder| enum.each do |*val| yielder.yield(*val) end end end |