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 entries to STDOUT only if their level is at least INFO OR the progname is “rails”:
processor = Sawmill::EntryProcessor.build do If(Any(FilterByBasicFields(:level => :INFO), FilterByBasicFields(:progname => 'rails')), 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/entry_processor/conditionals.rb, line 399 def initialize(*children_) @children = _interpret_processor_array(children_) end
# File lib/sawmill/entry_processor/conditionals.rb, line 421 def attribute(entry_) @children.inject(false) do |result_, child_| child_.attribute(entry_) || result_ end end
# File lib/sawmill/entry_processor/conditionals.rb, line 403 def begin_record(entry_) @children.inject(false) do |result_, child_| child_.begin_record(entry_) || result_ end end
# File lib/sawmill/entry_processor/conditionals.rb, line 409 def end_record(entry_) @children.inject(false) do |result_, child_| child_.end_record(entry_) || result_ end end
# File lib/sawmill/entry_processor/conditionals.rb, line 433 def finish Util::ProcessorTools.collect_finish_values(@children) end
# File lib/sawmill/entry_processor/conditionals.rb, line 415 def message(entry_) @children.inject(false) do |result_, child_| child_.message(entry_) || result_ end end
# File lib/sawmill/entry_processor/conditionals.rb, line 427 def unknown_data(entry_) @children.inject(false) do |result_, child_| child_.unknown_data(entry_) || result_ end end