Class: Sawmill::EntryProcessor::FilterByBlock
- Inherits:
-
Base
- Object
- Base
- Sawmill::EntryProcessor::FilterByBlock
show all
- Defined in:
- lib/sawmill/entry_processor/filter_by_block.rb
Overview
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.
Instance Method Summary
collapse
Methods inherited from Base
add_dsl_method, inherited
Constructor Details
Create a new filter. Provide the block, which should take an entry object as the parameter and return a boolean.
54
55
56
|
# File 'lib/sawmill/entry_processor/filter_by_block.rb', line 54
def initialize(&block_)
to_filter_entry(&block_)
end
|
Instance Method Details
#attribute(entry_) ⇒ Object
79
80
81
|
# File 'lib/sawmill/entry_processor/filter_by_block.rb', line 79
def attribute(entry_)
@block.call(entry_)
end
|
#begin_record(entry_) ⇒ Object
67
68
69
|
# File 'lib/sawmill/entry_processor/filter_by_block.rb', line 67
def begin_record(entry_)
@block.call(entry_)
end
|
#end_record(entry_) ⇒ Object
71
72
73
|
# File 'lib/sawmill/entry_processor/filter_by_block.rb', line 71
def end_record(entry_)
@block.call(entry_)
end
|
#finish ⇒ Object
87
88
89
|
# File 'lib/sawmill/entry_processor/filter_by_block.rb', line 87
def finish
nil
end
|
#message(entry_) ⇒ Object
75
76
77
|
# File 'lib/sawmill/entry_processor/filter_by_block.rb', line 75
def message(entry_)
@block.call(entry_)
end
|
#to_filter_entry(&block_) ⇒ Object
Provide a block to filter entries. It should take an entry object as the parameter, and return a boolean.
62
63
64
|
# 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_) ⇒ Object
83
84
85
|
# File 'lib/sawmill/entry_processor/filter_by_block.rb', line 83
def unknown_data(entry_)
@block.call(entry_)
end
|