Class: ActiveRecord::ConnectionAdapters::MysqlSpatialAdapter::SpatialColumn
- Inherits:
-
ConnectionAdapters::MysqlColumn
- Object
- ConnectionAdapters::MysqlColumn
- ActiveRecord::ConnectionAdapters::MysqlSpatialAdapter::SpatialColumn
- Defined in:
- lib/active_record/connection_adapters/mysqlspatial_adapter/spatial_column.rb
Instance Attribute Summary collapse
-
#geometric_type ⇒ Object
readonly
Returns the value of attribute geometric_type.
Instance Method Summary collapse
-
#initialize(name_, default_, sql_type_ = nil, null_ = true) ⇒ SpatialColumn
constructor
A new instance of SpatialColumn.
- #klass ⇒ Object
- #set_ar_class(val_) ⇒ Object
- #spatial? ⇒ Boolean
- #type_cast(value_) ⇒ Object
- #type_cast_code(var_name_) ⇒ Object
Constructor Details
#initialize(name_, default_, sql_type_ = nil, null_ = true) ⇒ SpatialColumn
Returns a new instance of SpatialColumn.
49 50 51 52 53 54 55 56 |
# File 'lib/active_record/connection_adapters/mysqlspatial_adapter/spatial_column.rb', line 49 def initialize(name_, default_, sql_type_=nil, null_=true) super(name_, default_, sql_type_, null_) @geometric_type = ::RGeo::ActiveRecord.geometric_type_from_name(sql_type_) if type == :spatial @limit = {:type => @geometric_type.type_name.underscore} end @ar_class = ::ActiveRecord::Base end |
Instance Attribute Details
#geometric_type ⇒ Object (readonly)
Returns the value of attribute geometric_type.
64 65 66 |
# File 'lib/active_record/connection_adapters/mysqlspatial_adapter/spatial_column.rb', line 64 def geometric_type @geometric_type end |
Instance Method Details
#klass ⇒ Object
72 73 74 |
# File 'lib/active_record/connection_adapters/mysqlspatial_adapter/spatial_column.rb', line 72 def klass type == :spatial ? ::RGeo::Feature::Geometry : super end |
#set_ar_class(val_) ⇒ Object
59 60 61 |
# File 'lib/active_record/connection_adapters/mysqlspatial_adapter/spatial_column.rb', line 59 def set_ar_class(val_) @ar_class = val_ end |
#spatial? ⇒ Boolean
67 68 69 |
# File 'lib/active_record/connection_adapters/mysqlspatial_adapter/spatial_column.rb', line 67 def spatial? type == :spatial end |
#type_cast(value_) ⇒ Object
77 78 79 |
# File 'lib/active_record/connection_adapters/mysqlspatial_adapter/spatial_column.rb', line 77 def type_cast(value_) type == :spatial ? SpatialColumn.convert_to_geometry(value_, @ar_class, name) : super end |
#type_cast_code(var_name_) ⇒ Object
82 83 84 |
# File 'lib/active_record/connection_adapters/mysqlspatial_adapter/spatial_column.rb', line 82 def type_cast_code(var_name_) type == :spatial ? "::ActiveRecord::ConnectionAdapters::MysqlSpatialAdapter::SpatialColumn.convert_to_geometry(#{var_name_}, self.class, #{name.inspect})" : super end |