Class: Agilibox::SmallData::FilterStrategyByKeyValues
- Inherits:
-
FilterStrategy
- Object
- FilterStrategy
- Agilibox::SmallData::FilterStrategyByKeyValues
- Defined in:
- app/filters/agilibox/small_data/filter_strategy_by_key_values.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #apply(query, value) ⇒ Object
-
#initialize(key = nil) ⇒ FilterStrategyByKeyValues
constructor
A new instance of FilterStrategyByKeyValues.
Constructor Details
#initialize(key = nil) ⇒ FilterStrategyByKeyValues
Returns a new instance of FilterStrategyByKeyValues.
4 5 6 |
# File 'app/filters/agilibox/small_data/filter_strategy_by_key_values.rb', line 4 def initialize(key = nil) @key = key end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
2 3 4 |
# File 'app/filters/agilibox/small_data/filter_strategy_by_key_values.rb', line 2 def key @key end |
Instance Method Details
#apply(query, value) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'app/filters/agilibox/small_data/filter_strategy_by_key_values.rb', line 8 def apply(query, value) value = value.split(" ") if value.is_a?(String) value = value.select(&:present?) if value.any? query.where("#{key} IN (?)", value) else query end end |