Sha256: ba4598e53ff7c694c45911452a657f68857c77e8ab0e08111238c3901599db51

Contents?: true

Size: 620 Bytes

Versions: 2

Compression:

Stored size: 620 Bytes

Contents

require 'geo_ruby'
require 'dm-core'

module DataMapper
  class Property
    class DMGeometry < Object
      include GeoRuby::SimpleFeatures

      def primitive?(value)
        value.kind_of? Geometry
      end

      def dump(value)
        value.nil? ? nil : value.as_hex_ewkb
      end

      def valid?(value, negated = false)
        super || dump(value).kind_of?(::String)
      end

      def load(value)
        value.nil? ? nil : Geometry.from_hex_ewkb(value)
      end
    
      def typecast_to_primitive(value)
        load(value)
      end
    end # class Text
  end # module Types
end # module DataMapper

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dm-postgis-1.2.4 lib/dm-postgis.rb
dm-postgis-1.2.3 lib/dm-postgis.rb