lib/mongoid_geospatial/wrappers/rgeo.rb in mongoid_geospatial-2.2.0 vs lib/mongoid_geospatial/wrappers/rgeo.rb in mongoid_geospatial-2.3.0

- old
+ new

@@ -3,16 +3,28 @@ module Mongoid module Geospatial class Point + delegate :distance, :to => :to_geo + def to_geo RGeo::Geographic.spherical_factory.point x, y end + + def self.mongoize(obj) + case obj + when RGeo::Geographic::SphericalPointImpl then [obj.x, obj.y] + when Point then obj.mongoize + when Array then obj.to_xy + when Hash then obj.to_xy + else obj + end + end end - class LineString < GeometryField + class Line < GeometryField def to_geo RGeo::Geographic.spherical_factory.line_string self end end