Class: ActiveRecord::ConnectionAdapters::PostgreSQLColumn
- Inherits:
-
Column
- Object
- Column
- ActiveRecord::ConnectionAdapters::PostgreSQLColumn
- Defined in:
- lib/activerecord-postgres-postgis/active_record/connection_adapters/column.rb
Instance Attribute Summary collapse
-
#oid_type ⇒ Object
Returns the value of attribute oid_type.
-
#spatial_type ⇒ Object
readonly
Returns the value of attribute spatial_type.
-
#srid ⇒ Object
readonly
Returns the value of attribute srid.
Instance Method Summary collapse
- #initialize_with_spatial(name, default, oid_type, sql_type = nil, null = true) ⇒ Object
- #simplified_type_with_spatial(field_type) ⇒ Object
- #spatial? ⇒ Boolean
Instance Attribute Details
#oid_type ⇒ Object
Returns the value of attribute oid_type.
6 7 8 |
# File 'lib/activerecord-postgres-postgis/active_record/connection_adapters/column.rb', line 6 def oid_type @oid_type end |
#spatial_type ⇒ Object (readonly)
Returns the value of attribute spatial_type.
4 5 6 |
# File 'lib/activerecord-postgres-postgis/active_record/connection_adapters/column.rb', line 4 def spatial_type @spatial_type end |
#srid ⇒ Object (readonly)
Returns the value of attribute srid.
4 5 6 |
# File 'lib/activerecord-postgres-postgis/active_record/connection_adapters/column.rb', line 4 def srid @srid end |
Instance Method Details
#initialize_with_spatial(name, default, oid_type, sql_type = nil, null = true) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/activerecord-postgres-postgis/active_record/connection_adapters/column.rb', line 8 def initialize_with_spatial(name, default, oid_type, sql_type = nil, null = true) initialize_without_spatial(name, default, oid_type, sql_type, null) @spatial_type = extract_spatial_type(sql_type) @srid = extract_srid(sql_type) if spatial? oid_type.srid = @srid end end |
#simplified_type_with_spatial(field_type) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/activerecord-postgres-postgis/active_record/connection_adapters/column.rb', line 21 def simplified_type_with_spatial(field_type) if field_type =~ /^(?:geometry)/ :geometry elsif field_type =~ /^(?:geography)/ :geography else simplified_type_without_spatial(field_type) end end |
#spatial? ⇒ Boolean
33 34 35 |
# File 'lib/activerecord-postgres-postgis/active_record/connection_adapters/column.rb', line 33 def spatial? !sql_type.match(/^(geometry|geography)/).nil? end |