Class: Sawmill::EntryProcessor::FilterByMessage

Inherits:
Base
  • Object
show all
Defined in:
lib/sawmill/entry_processor/filter_by_message.rb

Overview

A basic filter that knows how to check message content.

This is a boolean processor, so it merely returns true or false based on the filter result. Use this in conjunction with an If processor to actually perform other actions based on the result.

Instance Method Summary collapse

Methods inherited from Base

add_dsl_method, inherited

Constructor Details

#initialize(content_, opts_ = {}) ⇒ FilterByMessage

Create a new filter. you must provide content, which can be a string or a regex.

Recognized options include:

:accept_non_messages

If set to true, accepts entries that are not messages. Otherwise, if set to false or not specified, rejects such entries.



60
61
62
63
# File 'lib/sawmill/entry_processor/filter_by_message.rb', line 60

def initialize(content_, opts_={})
  @content = content_
  @accept_non_messages = opts_[:accept_non_messages] ? true : false
end

Instance Method Details

#attribute(entry_) ⇒ Object



78
79
80
# File 'lib/sawmill/entry_processor/filter_by_message.rb', line 78

def attribute(entry_)
  @accept_non_messages
end

#begin_record(entry_) ⇒ Object



66
67
68
# File 'lib/sawmill/entry_processor/filter_by_message.rb', line 66

def begin_record(entry_)
  @accept_non_messages
end

#end_record(entry_) ⇒ Object



70
71
72
# File 'lib/sawmill/entry_processor/filter_by_message.rb', line 70

def end_record(entry_)
  @accept_non_messages
end

#finishObject



86
87
88
# File 'lib/sawmill/entry_processor/filter_by_message.rb', line 86

def finish
  nil
end

#message(entry_) ⇒ Object



74
75
76
# File 'lib/sawmill/entry_processor/filter_by_message.rb', line 74

def message(entry_)
  @content === entry_.message
end

#unknown_data(entry_) ⇒ Object



82
83
84
# File 'lib/sawmill/entry_processor/filter_by_message.rb', line 82

def unknown_data(entry_)
  @accept_non_messages
end