Module: Mongoid::Geospatial::ClassMethods
- Defined in:
- lib/mongoid/geospatial.rb
Overview
Methods applied to Document’s class
Instance Method Summary collapse
-
#spatial_index(name, options = {}) ⇒ Object
Create Spatial index for given field.
-
#spatial_scope(field, _opts = {}) ⇒ Object
Creates Sphere index for given field.
-
#sphere_index(name, options = {}) ⇒ Object
Creates Sphere index for given field.
Instance Method Details
#spatial_index(name, options = {}) ⇒ Object
Create Spatial index for given field
www.mongodb.org/display/DOCS/Geospatial+Indexing #GeospatialIndexing-geoNearCommand
84 85 86 87 |
# File 'lib/mongoid/geospatial.rb', line 84 def spatial_index(name, = {}) spatial_fields_indexed << name index({ name => '2d' }, ) end |
#spatial_scope(field, _opts = {}) ⇒ Object
Creates Sphere index for given field
www.mongodb.org/display/DOCS/Geospatial+Indexing #GeospatialIndexing-geoNearCommand
112 113 114 115 116 117 118 119 |
# 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 = {}) ⇒ Object
Creates Sphere index for given field
www.mongodb.org/display/DOCS/Geospatial+Indexing #GeospatialIndexing-geoNearCommand
98 99 100 101 |
# File 'lib/mongoid/geospatial.rb', line 98 def sphere_index(name, = {}) spatial_fields_indexed << name index({ name => '2dsphere' }, ) end |