Sha256: 00a50d76272666974a7ac8d48ec8980f535eabe1748cf88a0dc55c815d349647

Contents?: true

Size: 428 Bytes

Versions: 3

Compression:

Stored size: 428 Bytes

Contents

module Mongoid
  module Location
    class Point
      include Mongoid::Fields::Serializable

      def self.instantiate name, options = {}
        super
      end

      def serialize(object)
        object.respond_to?(:x) ? [object.x, object.y] : object
      end

      def deserialize(object)
        return unless object && !object.empty?
        RGeo::Geographic.spherical_factory.point *object
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongoid_location-0.3.5 lib/mongoid_location/fields/mongoid2/point.rb
mongoid_location-0.3.3 lib/mongoid_location/fields/mongoid2/point.rb
mongoid_location-0.3.2 lib/mongoid_location/fields/mongoid2/point.rb