Sha256: 4af033a723bafa03394e891c53ced4a2ed9229ffe7b2c456d6a74e5457c417e5

Contents?: true

Size: 676 Bytes

Versions: 3

Compression:

Stored size: 676 Bytes

Contents

require 'geo_ruby'
require 'dm-core'

module DataMapper
  class Property
    #class DMGeometry < GeoRuby::SimpleFeatures::Geometry
    class DMGeometry < Text
      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

3 entries across 3 versions & 1 rubygems

Version Path
dm-postgis-1.2.2 lib/dm-postgis.rb
dm-postgis-1.2.1 lib/dm-postgis.rb
dm-postgis-1.2.0 lib/dm-postgis.rb