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
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
# 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
# File lib/sawmill/record_processor/conditionals.rb, line 319 def finish Util::ProcessorTools.collect_finish_values(@children) end
# File lib/sawmill/record_processor/conditionals.rb, line 307 def record(record_) @children.inject(false) do |result_, child_| child_.record(record_) || result_ end end