Class: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::Spatial
- Inherits:
-
Type
- Object
- Type
- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::Spatial
- Defined in:
- lib/activerecord-postgres-postgis/active_record/connection_adapters/oid.rb
Instance Attribute Summary collapse
-
#factory_generator ⇒ Object
Returns the value of attribute factory_generator.
-
#srid ⇒ Object
Returns the value of attribute srid.
Instance Method Summary collapse
-
#initialize(factory_generator = nil) ⇒ Spatial
constructor
A new instance of Spatial.
- #type_cast(value) ⇒ Object
Constructor Details
#initialize(factory_generator = nil) ⇒ Spatial
Returns a new instance of Spatial.
8 9 10 |
# File 'lib/activerecord-postgres-postgis/active_record/connection_adapters/oid.rb', line 8 def initialize(factory_generator = nil) @factory_generator = factory_generator end |
Instance Attribute Details
#factory_generator ⇒ Object
Returns the value of attribute factory_generator.
6 7 8 |
# File 'lib/activerecord-postgres-postgis/active_record/connection_adapters/oid.rb', line 6 def factory_generator @factory_generator end |
#srid ⇒ Object
Returns the value of attribute srid.
6 7 8 |
# File 'lib/activerecord-postgres-postgis/active_record/connection_adapters/oid.rb', line 6 def srid @srid end |
Instance Method Details
#type_cast(value) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/activerecord-postgres-postgis/active_record/connection_adapters/oid.rb', line 12 def type_cast(value) if value.kind_of?(RGeo::Feature::Geometry) RGeo::Feature.cast(value, @factory) elsif value && value.respond_to?(:to_s) marker = value[0, 1] if marker == "\x00" || marker == "\x01" || value[0,4] =~ /[0-9a-fA-F]{4}/ RGeo::WKRep::WKBParser.new(@factory_generator, support_ewkb: true, default_srid: srid).parse(value) else RGeo::WKRep::WKTParser.new(@factory_generator, support_ewkt: true, default_srid: srid).parse(value) end else nil end end |