class Sawmill::RecordProcessor::Or

A boolean processor that returns true if and only if any of its child processors returns true. This version short-circuits the processing, so once one child returns true, subsequent children are not called at all.

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(Or(FilterByAttributes('user' => 'daniel'),
        FilterByRecordID('12345678')),
     Format(STDOUT))
end

Public Class Methods

new(*children_) click to toggle source

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

# File lib/sawmill/record_processor/conditionals.rb, line 202
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 213
def extra_entry(entry_)
  @children.each do |child_|
    return true if child_.extra_entry(entry_)
  end
  false
end
finish() click to toggle source
# File lib/sawmill/record_processor/conditionals.rb, line 220
def finish
  Util::ProcessorTools.collect_finish_values(@children)
end
record(record_) click to toggle source
# File lib/sawmill/record_processor/conditionals.rb, line 206
def record(record_)
  @children.each do |child_|
    return true if child_.record(record_)
  end
  false
end