Class: Stretchy::Filters::RangeFilter

Inherits:
Base
  • Object
show all
Defined in:
lib/stretchy/filters/range_filter.rb

Instance Method Summary collapse

Methods included from Utils::Validation

#errors, included, #require_one!, #require_only_one!, #valid?, #validate!, #validator

Constructor Details

#initialize(field, range_options) ⇒ RangeFilter

Returns a new instance of RangeFilter.



16
17
18
19
20
# File 'lib/stretchy/filters/range_filter.rb', line 16

def initialize(field, range_options)
  @field = field
  @range = Types::Range.new(range_options)
  validate!
end

Instance Method Details

#to_searchObject



22
23
24
25
26
27
28
# File 'lib/stretchy/filters/range_filter.rb', line 22

def to_search
  {
    range: {
      @field => @range.to_search
    }
  }
end