Module: Async::Enumerable::Methods::Each
- Included in:
- Async::Enumerable::Methods
- Defined in:
- lib/async/enumerable/methods/each.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#each {|item| ... } ⇒ self, Enumerator
Executes block for each element in parallel.
Class Method Details
.included(base) ⇒ Object
7 8 9 10 11 |
# File 'lib/async/enumerable/methods/each.rb', line 7 def self.included(base) base.include(::Enumerable) # Dependency base.include(ConcurrencyBounder) # Dependency base.include(Configurable) # Dependency for collection resolution end |
Instance Method Details
#each {|item| ... } ⇒ self, Enumerator
Executes block for each element in parallel.
This is the core of Async::Enumerable, as most of the enumerable
methods require #each in order to function. This definition of each
is automatically included when Async::Enumerable is included, but it
can be overridden by the including class. Here be dragons, though.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/async/enumerable/methods/each.rb', line 22 def each(&block) return enum_for(__method__) unless block_given? __async_enumerable_bounded_concurrency do || __async_enumerable_collection.each do |item| .async do block.call(item) end end end # Return self to allow chaining, like standard each self end |