Module: Mongoid::Indexes::ClassMethods

Defined in:
lib/mongoid/geo/index.rb

Overview

:nodoc

Instance Method Summary collapse

Instance Method Details

#geo_index(name, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/mongoid/geo/index.rb', line 4

def geo_index name, options = {}
  min = options[:min] || -180
  max = options[:max] || 180
  index [[ name, Mongo::GEO2D ]], :min => min, :max => max

  define_singleton_method :create_index! do
    collection.create_index([[name, Mongo::GEO2D]], :min => min, :max => max)
  end
end