Sha256: e72324c7394a1a3257515a4a650cd54da3726bd758a03ef733334d6850a2384f

Contents?: true

Size: 885 Bytes

Versions: 2

Compression:

Stored size: 885 Bytes

Contents

require 'geocoder2/models/base'
require 'geocoder2/models/mongo_base'

module Geocoder2
  module Model
    module Mongoid
      include Base
      include MongoBase

      def self.included(base); base.extend(self); end

      private # --------------------------------------------------------------

      def geocoder2_file_name;   "mongoid"; end
      def geocoder2_module_name; "Mongoid"; end

      def geocoder2_init(options)
        super(options)
        if options[:skip_index] == false
          # create 2d index
          if defined?(::Mongoid::VERSION) && ::Mongoid::VERSION >= "3"
            index({ geocoder2_options[:coordinates].to_sym => '2d' }, 
                  {:min => -180, :max => 180})
          else
            index [[ geocoder2_options[:coordinates], '2d' ]],
              :min => -180, :max => 180
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
geocoder2-0.1.1 lib/geocoder2/models/mongoid.rb
geocoder2-0.1.0 lib/geocoder2/models/mongoid.rb