A record filter that checks attribute values.
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.
Create a new filter. Pass the attribute names and values to check as a hash.
# File lib/sawmill/record_processor/filter_by_attributes.rb, line 54 def initialize(attributes_) @attributes = {} attributes_.each{ |key_, value_| @attributes[key_.to_s] = value_ } end
# File lib/sawmill/record_processor/filter_by_attributes.rb, line 75 def extra_entry(entry_) false end
# File lib/sawmill/record_processor/filter_by_attributes.rb, line 79 def finish nil end
# File lib/sawmill/record_processor/filter_by_attributes.rb, line 60 def record(record_) @attributes.each do |key_, value_| record_value_ = record_.attribute(key_.to_s) case record_value_ when ::Array return false unless record_value_.find{ |rval_| value_ === rval_ } when ::String return false unless value_ === record_value_ when nil return false unless value_.nil? end end true end