Module: Mongoid::Location::ClassMethods

Defined in:
lib/mongoid_location/location.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

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

create spatial index for given field

Parameters:

  • name (String, Symbol)
  • options (Hash) (defaults to: {})

    options for spatial_index



55
56
57
58
59
60
61
62
63
64
# File 'lib/mongoid_location/location.rb', line 55

def spatial_index name, options = {}
  self.spatial_fields_indexed << name
  # fix 3.x version
  if Mongoid::VERSION =~ /^3.\d/
  #if Mongoid::VERSION =~ /3.0/
    index({name => '2d'}, options)
  else
    index [[name, '2d']], options
  end
end