Class: Stretchy::Filters::BoolFilter
- Defined in:
- lib/stretchy/filters/bool_filter.rb
Constant Summary
Constants included from Utils::Contract
Utils::Contract::ASSERTIONS, Utils::Contract::DECAY_FUNCTIONS, Utils::Contract::DISTANCE_FORMAT
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ BoolFilter
constructor
A new instance of BoolFilter.
- #to_search ⇒ Object
Methods included from Utils::Contract
included, #require_one, #validate!
Constructor Details
#initialize(options = {}) ⇒ BoolFilter
11 12 13 14 15 16 17 |
# File 'lib/stretchy/filters/bool_filter.rb', line 11 def initialize( = {}) @must = Array([:must]) @must_not = Array([:must_not]) @should = Array([:should]) validate! require_one(must: @must, must_not: @must_not, should: @should) end |
Instance Method Details
#to_search ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/stretchy/filters/bool_filter.rb', line 19 def to_search json = {} json[:must] = @must.map(&:to_search) if @must.any? json[:must_not] = @must_not.map(&:to_search) if @must_not.any? json[:should] = @should.map(&:to_search) if @should.any? { bool: json } end |