module Mongoid::Geospatial::ClassMethods
Methods applied to Document's class
Public Instance Methods
spatial_index(name, options = {})
click to toggle source
Create Spatial index for given field
@param [String,Symbol] name @param [Hash] options options for spatial_index
www.mongodb.org/display/DOCS/Geospatial+Indexing #GeospatialIndexing-geoNearCommand
# File lib/mongoid/geospatial.rb, line 84 def spatial_index(name, options = {}) spatial_fields_indexed << name index({ name => '2d' }, options) end
spatial_scope(field, _opts = {})
click to toggle source
Creates Sphere index for given field
@param [String,Symbol] name @param [Hash] options options for spatial_index
www.mongodb.org/display/DOCS/Geospatial+Indexing #GeospatialIndexing-geoNearCommand
# File lib/mongoid/geospatial.rb, line 112 def spatial_scope(field, _opts = {}) singleton_class.class_eval do # define_method(:close) do |args| define_method(:nearby) do |args| queryable.where(field.near_sphere => args) end end end
sphere_index(name, options = {})
click to toggle source
Creates Sphere index for given field
@param [String,Symbol] name @param [Hash] options options for spatial_index
www.mongodb.org/display/DOCS/Geospatial+Indexing #GeospatialIndexing-geoNearCommand
# File lib/mongoid/geospatial.rb, line 98 def sphere_index(name, options = {}) spatial_fields_indexed << name index({ name => '2dsphere' }, options) end