Class: Stretchy::Filters::GeoFilter

Inherits:
Base
  • Object
show all
Defined in:
lib/stretchy/filters/geo_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, distance, geo_point) ⇒ GeoFilter

Returns a new instance of GeoFilter.



18
19
20
21
22
23
# File 'lib/stretchy/filters/geo_filter.rb', line 18

def initialize(field, distance, geo_point)
  @field      = field
  @distance   = distance
  @geo_point  = Types::GeoPoint.new(geo_point)
  validate!
end

Instance Method Details

#to_searchObject



25
26
27
28
29
30
31
32
# File 'lib/stretchy/filters/geo_filter.rb', line 25

def to_search
  {
    geo_distance: {
      distance: @distance,
      @field => @geo_point.to_search
    }
  }
end