1
0
mirror of https://github.com/meineerde/rackstash.git synced 2025-12-19 15:01:12 +00:00

Make Flow#unshift_filter the primary alias before filter_prepend to be more consistent

This commit is contained in:
Holger Just 2017-08-05 23:19:23 +02:00
parent 581b8b1819
commit d362b7efaa
2 changed files with 7 additions and 7 deletions

View File

@ -166,11 +166,11 @@ module Rackstash
end end
# (see FilterChain#unshift) # (see FilterChain#unshift)
def filter_prepend(*filter, &block) def filter_unshift(*filter, &block)
@filter_chain.unshift(*filter, &block) @filter_chain.unshift(*filter, &block)
self self
end end
alias filter_unshift filter_prepend alias filter_prepend filter_unshift
# Re-open the log adapter if supported. This might be a no-op if the adapter # Re-open the log adapter if supported. This might be a no-op if the adapter
# does not support reopening. This method is called by the logger's {Sink}. # does not support reopening. This method is called by the logger's {Sink}.

View File

@ -213,18 +213,18 @@ describe Rackstash::Flow do
end end
end end
describe '#filter_prepend' do describe '#filter_unshift' do
it 'calls FilterChain#unshift' do it 'calls FilterChain#unshift' do
expect(flow.filter_chain).to receive(:unshift).twice.and_call_original expect(flow.filter_chain).to receive(:unshift).twice.and_call_original
expect(flow.filter_prepend ->(event) { event }).to equal flow expect(flow.filter_unshift ->(event) { event }).to equal flow
expect(flow.filter_prepend { |event| event }).to equal flow expect(flow.filter_unshift { |event| event }).to equal flow
expect(flow.filter_chain.size).to eql 2 expect(flow.filter_chain.size).to eql 2
end end
it 'can use the #filter_unshift alias' do it 'can use the #filter_prepend alias' do
expect(flow.method(:filter_unshift)).to eql flow.method(:filter_prepend) expect(flow.method(:filter_prepend)).to eql flow.method(:filter_unshift)
end end
end end