Class: Philiprehberger::LogFilter::ChainedFilter Private
- Defined in:
- lib/philiprehberger/log_filter/filter.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A filter produced by Filter#chain that pipes events through two source filters in order. Tracks its own stats independently of the inputs. Short-circuits when the first filter drops the event.
Instance Attribute Summary
Attributes inherited from Filter
Instance Method Summary collapse
-
#apply(message) ⇒ String?
private
Run
first.applythensecond.apply. -
#initialize(first, second) ⇒ ChainedFilter
constructor
private
A new instance of ChainedFilter.
Methods inherited from Filter
#chain, #drop, #drop_field, #drop_if, #mask_field, #replace, #reset_stats!, #sample, #stats
Constructor Details
#initialize(first, second) ⇒ ChainedFilter
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ChainedFilter.
238 239 240 241 242 |
# File 'lib/philiprehberger/log_filter/filter.rb', line 238 def initialize(first, second) super() @first = first @second = second end |
Instance Method Details
#apply(message) ⇒ String?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Run first.apply then second.apply. If the first returns nil, the second is skipped and nil is returned.
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/philiprehberger/log_filter/filter.rb', line 249 def apply() intermediate = @first.apply() if intermediate.nil? increment_stat(:dropped) return nil end result = @second.apply(intermediate) if result.nil? increment_stat(:dropped) return nil end increment_stat(:passed) result end |