Class: ActiveRecord::ConnectionAdapters::Mysql2Rgeo::SpatialColumn
- Inherits:
-
ConnectionAdapters::MySQL::Column
- Object
- ConnectionAdapters::MySQL::Column
- ActiveRecord::ConnectionAdapters::Mysql2Rgeo::SpatialColumn
- Defined in:
- lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#geometric_type ⇒ Object
readonly
Returns the value of attribute geometric_type.
-
#srid ⇒ Object
readonly
Returns the value of attribute srid.
Instance Method Summary collapse
- #geographic ⇒ Object (also: #geographic?)
- #has_m ⇒ Object (also: #has_m?)
- #has_z ⇒ Object (also: #has_z?)
-
#initialize(name, default, sql_type_metadata = nil, null = true, default_function = nil, collation: nil, comment: nil, spatial: nil) ⇒ SpatialColumn
constructor
A new instance of SpatialColumn.
- #limit ⇒ Object
- #multi? ⇒ Boolean
- #spatial? ⇒ Boolean
Constructor Details
#initialize(name, default, sql_type_metadata = nil, null = true, default_function = nil, collation: nil, comment: nil, spatial: nil) ⇒ SpatialColumn
Returns a new instance of SpatialColumn.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 7 def initialize(name, default, = nil, null = true, default_function = nil, collation: nil, comment: nil, spatial: nil, **) @sql_type_metadata = if spatial # This case comes from an entry in the geometry_columns table set_geometric_type_from_name(spatial[:type]) @srid = spatial[:srid].to_i elsif sql_type =~ /geometry|point|linestring|polygon/i build_from_sql_type(.sql_type) elsif .sql_type =~ /geometry|point|linestring|polygon/i # A geometry column with no geometry_columns entry. # @geometric_type = geo_type_from_sql_type(sql_type) build_from_sql_type(.sql_type) end super(name, default, , null, default_function, collation: collation, comment: comment) if spatial? if @srid @limit = { type: geometric_type.type_name.underscore, srid: @srid } end end end |
Instance Attribute Details
#geometric_type ⇒ Object (readonly)
Returns the value of attribute geometric_type.
28 29 30 |
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 28 def geometric_type @geometric_type end |
#srid ⇒ Object (readonly)
Returns the value of attribute srid.
28 29 30 |
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 28 def srid @srid end |
Instance Method Details
#geographic ⇒ Object Also known as: geographic?
38 39 40 |
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 38 def geographic false end |
#has_m ⇒ Object Also known as: has_m?
34 35 36 |
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 34 def has_m false end |
#has_z ⇒ Object Also known as: has_z?
30 31 32 |
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 30 def has_z false end |
#limit ⇒ Object
50 51 52 |
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 50 def limit spatial? ? @limit : super end |
#multi? ⇒ Boolean
46 47 48 |
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 46 def multi? /^(geometrycollection|multi)/i.match?(sql_type) end |
#spatial? ⇒ Boolean
54 55 56 |
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 54 def spatial? %i[geometry geography].include?(@sql_type_metadata.type) end |