class Sawmill::RecordProcessor::Any

A boolean processor that returns true if and only if any of its child processors returns true. This version does not short-circuit the processing, so all children are always called even if an early one returns true.

For example, this builds a processor that sends formatted log records to STDOUT only if they have a “user” attribute of “daniel” OR their record ID is ‘12345678’:

processor = Sawmill::RecordProcessor.build do
  If(Any(FilterByAttributes('user' => 'daniel'),
         FilterByRecordID('12345678')),
     Format(STDOUT))
end

Public Class Methods

new(*children_) click to toggle source

Create an “any” boolean. The parameters are child processors whose return values should be combined with an OR operation.

# File lib/sawmill/record_processor/conditionals.rb, line 303
def initialize(*children_)
  @children = _interpret_processor_array(children_)
end

Public Instance Methods

extra_entry(entry_) click to toggle source
# File lib/sawmill/record_processor/conditionals.rb, line 313
def extra_entry(entry_)
  @children.inject(false) do |result_, child_|
    child_.extra_entry(entry_) || result_
  end
end
finish() click to toggle source
# File lib/sawmill/record_processor/conditionals.rb, line 319
def finish
  Util::ProcessorTools.collect_finish_values(@children)
end
record(record_) click to toggle source
# File lib/sawmill/record_processor/conditionals.rb, line 307
def record(record_)
  @children.inject(false) do |result_, child_|
    child_.record(record_) || result_
  end
end