diff --git a/lib/rackstash/flow.rb b/lib/rackstash/flow.rb index 9271122..b5b3611 100644 --- a/lib/rackstash/flow.rb +++ b/lib/rackstash/flow.rb @@ -137,6 +137,14 @@ module Rackstash @auto_flush end + # Enable the {#auto_flush} feature for the current flow. + # + # @return [true] + # @see #auto_flush + def auto_flush! + self.auto_flush = true + end + # @param bool [Bool] `true` to cause buffering Buffers to write their added # messages and fields to the flow as soon as they are logged, `false` to # write the whole event only on an explicit call to {Buffer#flush}. diff --git a/spec/rackstash/flow_spec.rb b/spec/rackstash/flow_spec.rb index 40e561d..5aca13b 100644 --- a/spec/rackstash/flow_spec.rb +++ b/spec/rackstash/flow_spec.rb @@ -113,6 +113,13 @@ RSpec.describe Rackstash::Flow do end end + describe '#auto_flush!' do + it 'enables the auto_flush property' do + flow.auto_flush! + expect(flow.auto_flush?).to eql true + end + end + describe '#close!' do it 'calls adapter#close' do expect(adapter).to receive(:close).and_return(true)