Class: Stretchy::Filters::BoolFilter
- Defined in:
- lib/stretchy/filters/bool_filter.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ BoolFilter
constructor
A new instance of BoolFilter.
- #to_search ⇒ Object
Methods included from Utils::Validation
#errors, included, #require_one!, #require_only_one!, #valid?, #validate!, #validator
Constructor Details
#initialize(options = {}) ⇒ BoolFilter
Returns a new instance of BoolFilter.
17 18 19 20 21 22 23 |
# File 'lib/stretchy/filters/bool_filter.rb', line 17 def initialize( = {}) @must = Array([:must]) @must_not = Array([:must_not]) @should = Array([:should]) require_one!(:must, :must_not, :should) validate! end |
Instance Method Details
#to_search ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/stretchy/filters/bool_filter.rb', line 25 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 |