mirror of
https://github.com/meineerde/rackstash.git
synced 2025-12-19 15:01:12 +00:00
Return the flows object in Rackstash::Flows#each
This commit is contained in:
parent
1da5ae4a38
commit
364426f228
@ -61,17 +61,18 @@ module Rackstash
|
|||||||
# a parameter. We only yield non-nil elements. Concurrent changes to `self`
|
# a parameter. We only yield non-nil elements. Concurrent changes to `self`
|
||||||
# do not affect the running enumeration.
|
# do not affect the running enumeration.
|
||||||
#
|
#
|
||||||
# An Enumerator is returned if no block is given.
|
# An `Enumerator` is returned if no block is given.
|
||||||
#
|
#
|
||||||
# @yield [flow] calls the given block once for each flow
|
# @yield [flow] calls the given block once for each flow
|
||||||
# @yieldparam flow [Flow] the yielded flow
|
# @yieldparam flow [Flow] the yielded flow
|
||||||
# @return [Enumerator, Array<Flow>] Returns an array of the flows if a
|
# @return [Enumerator, self] `self` if a block was given or an `Enumerator`
|
||||||
# block was given or an `Enumerator` if no block was given.
|
# if no block was given.
|
||||||
def each
|
def each
|
||||||
return enum_for(__method__) unless block_given?
|
return enum_for(__method__) unless block_given?
|
||||||
to_a.each do |flow|
|
to_a.each do |flow|
|
||||||
yield flow
|
yield flow
|
||||||
end
|
end
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [Boolean] `true` if `self` contains no elements, `false` otherwise
|
# @return [Boolean] `true` if `self` contains no elements, `false` otherwise
|
||||||
|
|||||||
@ -128,9 +128,9 @@ describe Rackstash::Flows do
|
|||||||
expect { |b| flows.each(&b) }.to yield_control.once
|
expect { |b| flows.each(&b) }.to yield_control.once
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns an array if a block was provided' do
|
it 'returns the flow if a block was provided' do
|
||||||
flows << a_flow
|
flows << a_flow
|
||||||
expect(flows.each {}).to be_instance_of Array
|
expect(flows.each {}).to equal flows
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns an Enumerator if no block was provided' do
|
it 'returns an Enumerator if no block was provided' do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user