Sha256: 4bd0817a99b52dc0b8d67ffe78854a8bfaea40c8ac4ecd171ff1b433fefb91db
Contents?: true
Size: 850 Bytes
Versions: 2
Compression:
Stored size: 850 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, unit = nil, formula = nil) p1 = self.send(key) Mongoid::Spacial.distance(p1, p2, unit, formula = nil) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mongoid_spacial-0.2.5 | lib/mongoid_spacial/spacial/document.rb |
mongoid_spacial-0.2.4 | lib/mongoid_spacial/spacial/document.rb |