Class: DataFilter::LikeFilter
- Inherits:
-
Object
- Object
- DataFilter::LikeFilter
- Defined in:
- lib/data_filter/like_filter.rb
Overview
Used to filter a data item by a search term by seeing if the data field value is similar to the search term
Instance Method Summary collapse
-
#call(item) ⇒ Object?
Filters the item.
-
#initialize(field_sym, search_term) ⇒ LikeFilter
constructor
A new instance of LikeFilter.
Constructor Details
#initialize(field_sym, search_term) ⇒ LikeFilter
Returns a new instance of LikeFilter.
15 16 17 18 |
# File 'lib/data_filter/like_filter.rb', line 15 def initialize(field_sym, search_term) @field_sym = field_sym @search_term = search_term end |
Instance Method Details
#call(item) ⇒ Object?
Filters the item
24 25 26 27 28 29 |
# File 'lib/data_filter/like_filter.rb', line 24 def call(item) if item.respond_to?(@field_sym) && match?(item.public_send(@field_sym), @search_term) item end end |