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, #tap_each, #truncate
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.
290 291 292 293 294 |
# File 'lib/philiprehberger/log_filter/filter.rb', line 290 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.
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'lib/philiprehberger/log_filter/filter.rb', line 301 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 |