lib/mongoid_geospatial/fields/point.rb in mongoid_geospatial-1.0.0rc1 vs lib/mongoid_geospatial/fields/point.rb in mongoid_geospatial-1.0.0
- old
+ new
@@ -1,18 +1,16 @@
module Mongoid
module Geospatial
class Point
- include Mongoid::Fields::Serializable
-
- def deserialize(object)
+ def mongoize(object)
return unless object && !object.empty?
RGeo::Geographic.spherical_factory.point *object
#["x"], object["y"]
end
- def serialize(object)
+ def demongoize(object)
object.respond_to?(:x) ? [object.x, object.y] : object
# if object.respond_to? :x
# { "x" => object.x, "y" => object.y }
# else
# { "x" => object[0], "y" => object[1] }
@@ -34,11 +32,11 @@
# - end
# -
# - define_method "#{field.name}=" do |arg|
# - if arg.kind_of?(Hash) && arg[lng_meth] && arg[lat_meth]
# - arg = [arg[lng_meth].to_f, arg[lat_meth].to_f]
-# - elsif arg.respond_to?(:to_lng_lat)
-# - arg = arg.to_lng_lat
+# - elsif arg.respond_to?(:to_xy)
+# - arg = arg.to_xy
# - end
# - self[field.name]=arg
# - arg = [nil,nil] if arg.nil?
# - return arg[0..1] if options[:return_array]
# - h = {lng_meth => arg[0], lat_meth => arg[1]}