Sha256: 80a107de6a6adcbfbbed4e96ed264f72b9c82dfc1ab579bd3def0335a50e36cf

Contents?: true

Size: 612 Bytes

Versions: 3

Compression:

Stored size: 612 Bytes

Contents

module Mongoid
  module Location
    class Polygon
      # See http://mongoid.org/en/mongoid/docs/upgrading.html

      def mongoize
        self #.flatten
      end

      class << self
        def demongoize(object)
          points = object.map do |pair|
            RGeo::Geographic.spherical_factory.point *pair
          end
          ring = RGeo::Geographic.spherical_factory.linear_ring points
          RGeo::Geographic.spherical_factory.polygon ring
        end
        # def evolve(object)
        #   { "$gte" => object.first, "$lte" => object.last }
        # end
      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/polygon.rb
mongoid_location-0.3.3 lib/mongoid_location/fields/polygon.rb
mongoid_location-0.3.2 lib/mongoid_location/fields/polygon.rb