Class: Yuriita::SearchFilter
- Inherits:
-
Object
- Object
- Yuriita::SearchFilter
- Defined in:
- lib/yuriita/search_filter.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Instance Method Summary collapse
- #apply(relation, keywords) ⇒ Object
-
#initialize(input:, combination:, &block) ⇒ SearchFilter
constructor
A new instance of SearchFilter.
Constructor Details
#initialize(input:, combination:, &block) ⇒ SearchFilter
Returns a new instance of SearchFilter.
5 6 7 8 9 |
# File 'lib/yuriita/search_filter.rb', line 5 def initialize(input:, combination:, &block) @input = input @combination = combination @block = block end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
3 4 5 |
# File 'lib/yuriita/search_filter.rb', line 3 def input @input end |
Instance Method Details
#apply(relation, keywords) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/yuriita/search_filter.rb', line 11 def apply(relation, keywords) relations = keywords.map do |keyword| block.call(relation, keyword.to_s) end combination.new( base_relation: relation, relations: relations, ).combine end |