class Sawmill::RecordProcessor::FilterByBlock

A record 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 a Sawmill::Record as the parameter and return a boolean.

By default, extra entries always return false. Provide an extra entry filter to change this behavior.

# File lib/sawmill/record_processor/filter_by_block.rb, line 57
def initialize(&block_)
  to_filter_record(&block_)
end

Public Instance Methods

extra_entry(entry_) click to toggle source
# File lib/sawmill/record_processor/filter_by_block.rb, line 82
def extra_entry(entry_)
  @extra_entry_block.call(entry_)
end
finish() click to toggle source
# File lib/sawmill/record_processor/filter_by_block.rb, line 86
def finish
  nil
end
record(record_) click to toggle source
# File lib/sawmill/record_processor/filter_by_block.rb, line 78
def record(record_)
  @block.call(record_)
end
to_filter_extra_entry(&block_) click to toggle source

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

# File lib/sawmill/record_processor/filter_by_block.rb, line 73
def to_filter_extra_entry(&block_)
  @extra_entry_block = block_ || Proc.new{ |entry_| false }
end
to_filter_record(&block_) click to toggle source

Provide a block to filter records. It should take a Sawmill::Record as the parameter, and return a boolean.

# File lib/sawmill/record_processor/filter_by_block.rb, line 65
def to_filter_record(&block_)
  @block = block_ || Proc.new{ |record_| false }
end