class Sawmill::EntryProcessor::FilterByBlock

A entry filter that calls a block to perform its check.

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.

Public Class Methods

new(&block_) click to toggle source

Create a new filter. Provide the block, which should take an entry object as the parameter and return a boolean.

# File lib/sawmill/entry_processor/filter_by_block.rb, line 54
def initialize(&block_)
  to_filter_entry(&block_)
end

Public Instance Methods

attribute(entry_) click to toggle source
# File lib/sawmill/entry_processor/filter_by_block.rb, line 79
def attribute(entry_)
  @block.call(entry_)
end
begin_record(entry_) click to toggle source
# File lib/sawmill/entry_processor/filter_by_block.rb, line 67
def begin_record(entry_)
  @block.call(entry_)
end
end_record(entry_) click to toggle source
# File lib/sawmill/entry_processor/filter_by_block.rb, line 71
def end_record(entry_)
  @block.call(entry_)
end
finish() click to toggle source
# File lib/sawmill/entry_processor/filter_by_block.rb, line 87
def finish
  nil
end
message(entry_) click to toggle source
# File lib/sawmill/entry_processor/filter_by_block.rb, line 75
def message(entry_)
  @block.call(entry_)
end
to_filter_entry(&block_) click to toggle source

Provide a block to filter entries. It should take an entry object as the parameter, and return a boolean.

# File lib/sawmill/entry_processor/filter_by_block.rb, line 62
def to_filter_entry(&block_)
  @block = block_ || Proc.new{ |entry_| false }
end
unknown_data(entry_) click to toggle source
# File lib/sawmill/entry_processor/filter_by_block.rb, line 83
def unknown_data(entry_)
  @block.call(entry_)
end