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, #describe_rules, #drop, #drop_field, #drop_if, #explain, #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.
435 436 437 438 439 |
# File 'lib/philiprehberger/log_filter/filter.rb', line 435 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.
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
# File 'lib/philiprehberger/log_filter/filter.rb', line 446 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 |