Sha256: f6251230fce9eb55371d3150f50d5764bb41f9e154481230e0141e71134d5d64
Contents?: true
Size: 819 Bytes
Versions: 8
Compression:
Stored size: 819 Bytes
Contents
module Mongoid module Spacial module Document extend ActiveSupport::Concern included do attr_accessor :geo cattr_accessor :spacial_fields, :spacial_fields_indexed @@spacial_fields = [] @@spacial_fields_indexed = [] end module ClassMethods #:nodoc: # create spacial index for given field # @param [String,Symbol] name # @param [Hash] options options for spacial_index def spacial_index name, *options self.spacial_fields_indexed << name index [[ name, Mongo::GEO2D ]], *options end end module InstanceMethods #:nodoc: def distance_from(key,p2, opts = {}) p1 = self.send(key) Mongoid::Spacial.distance(p1, p2, opts) end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems